documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007
  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. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. 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>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. 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;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. 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;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. 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;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * 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".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * 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"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * 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)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * 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
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. 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;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * 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"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * 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".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * 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"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * 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".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * 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.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * 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)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @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
  5120. * @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
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. 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);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. 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>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. 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;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. 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;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. 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);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * 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;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * 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).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * 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).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * 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.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * 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.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * 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.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * 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.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * 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).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * 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).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * 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.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * 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.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * 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).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * 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).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * 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.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * 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.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * 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.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * 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.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * 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).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * 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).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * 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.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * 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.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * 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.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * 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.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: AbstractActionManager;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop 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 that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * 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
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @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
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @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
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @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
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @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
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. /**
  11027. * An event triggered when the manager is disposed.
  11028. */
  11029. onDisposeObservable: Observable<SpriteManager>;
  11030. private _onDisposeObserver;
  11031. /**
  11032. * Callback called when the manager is disposed
  11033. */
  11034. set onDispose(callback: () => void);
  11035. private _capacity;
  11036. private _fromPacked;
  11037. private _spriteTexture;
  11038. private _epsilon;
  11039. private _scene;
  11040. private _vertexData;
  11041. private _buffer;
  11042. private _vertexBuffers;
  11043. private _indexBuffer;
  11044. private _effectBase;
  11045. private _effectFog;
  11046. /**
  11047. * Gets or sets the unique id of the sprite
  11048. */
  11049. uniqueId: number;
  11050. /**
  11051. * Gets the array of sprites
  11052. */
  11053. get children(): Sprite[];
  11054. /**
  11055. * Gets the hosting scene
  11056. */
  11057. get scene(): Scene;
  11058. /**
  11059. * Gets the capacity of the manager
  11060. */
  11061. get capacity(): number;
  11062. /**
  11063. * Gets or sets the spritesheet texture
  11064. */
  11065. get texture(): Texture;
  11066. set texture(value: Texture);
  11067. private _blendMode;
  11068. /**
  11069. * Blend mode use to render the particle, it can be any of
  11070. * the static Constants.ALPHA_x properties provided in this class.
  11071. * Default value is Constants.ALPHA_COMBINE
  11072. */
  11073. get blendMode(): number;
  11074. set blendMode(blendMode: number);
  11075. /** Disables writing to the depth buffer when rendering the sprites.
  11076. * It can be handy to disable depth writing when using textures without alpha channel
  11077. * and setting some specific blend modes.
  11078. */
  11079. disableDepthWrite: boolean;
  11080. /**
  11081. * Creates a new sprite manager
  11082. * @param name defines the manager's name
  11083. * @param imgUrl defines the sprite sheet url
  11084. * @param capacity defines the maximum allowed number of sprites
  11085. * @param cellSize defines the size of a sprite cell
  11086. * @param scene defines the hosting scene
  11087. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11088. * @param samplingMode defines the smapling mode to use with spritesheet
  11089. * @param fromPacked set to false; do not alter
  11090. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11091. */
  11092. constructor(
  11093. /** defines the manager's name */
  11094. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11095. /**
  11096. * Returns the string "SpriteManager"
  11097. * @returns "SpriteManager"
  11098. */
  11099. getClassName(): string;
  11100. private _makePacked;
  11101. private _appendSpriteVertex;
  11102. private _checkTextureAlpha;
  11103. /**
  11104. * Intersects the sprites with a ray
  11105. * @param ray defines the ray to intersect with
  11106. * @param camera defines the current active camera
  11107. * @param predicate defines a predicate used to select candidate sprites
  11108. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11109. * @returns null if no hit or a PickingInfo
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Render all child sprites
  11122. */
  11123. render(): void;
  11124. /**
  11125. * Release associated resources
  11126. */
  11127. dispose(): void;
  11128. /**
  11129. * Serializes the sprite manager to a JSON object
  11130. * @param serializeTexture defines if the texture must be serialized as well
  11131. * @returns the JSON object
  11132. */
  11133. serialize(serializeTexture?: boolean): any;
  11134. /**
  11135. * Parses a JSON object to create a new sprite manager.
  11136. * @param parsedManager The JSON object to parse
  11137. * @param scene The scene to create the sprite managerin
  11138. * @param rootUrl The root url to use to load external dependencies like texture
  11139. * @returns the new sprite manager
  11140. */
  11141. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11142. /**
  11143. * Creates a sprite manager from a snippet saved in a remote file
  11144. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11145. * @param url defines the url to load from
  11146. * @param scene defines the hosting scene
  11147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11148. * @returns a promise that will resolve to the new sprite manager
  11149. */
  11150. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11151. /**
  11152. * Creates a sprite manager from a snippet saved by the sprite editor
  11153. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11154. * @param scene defines the hosting scene
  11155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11156. * @returns a promise that will resolve to the new sprite manager
  11157. */
  11158. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11159. }
  11160. }
  11161. declare module BABYLON {
  11162. /** Interface used by value gradients (color, factor, ...) */
  11163. export interface IValueGradient {
  11164. /**
  11165. * Gets or sets the gradient value (between 0 and 1)
  11166. */
  11167. gradient: number;
  11168. }
  11169. /** Class used to store color4 gradient */
  11170. export class ColorGradient implements IValueGradient {
  11171. /**
  11172. * Gets or sets the gradient value (between 0 and 1)
  11173. */
  11174. gradient: number;
  11175. /**
  11176. * Gets or sets first associated color
  11177. */
  11178. color1: Color4;
  11179. /**
  11180. * Gets or sets second associated color
  11181. */
  11182. color2?: Color4 | undefined;
  11183. /**
  11184. * Creates a new color4 gradient
  11185. * @param gradient gets or sets the gradient value (between 0 and 1)
  11186. * @param color1 gets or sets first associated color
  11187. * @param color2 gets or sets first second color
  11188. */
  11189. constructor(
  11190. /**
  11191. * Gets or sets the gradient value (between 0 and 1)
  11192. */
  11193. gradient: number,
  11194. /**
  11195. * Gets or sets first associated color
  11196. */
  11197. color1: Color4,
  11198. /**
  11199. * Gets or sets second associated color
  11200. */
  11201. color2?: Color4 | undefined);
  11202. /**
  11203. * Will get a color picked randomly between color1 and color2.
  11204. * If color2 is undefined then color1 will be used
  11205. * @param result defines the target Color4 to store the result in
  11206. */
  11207. getColorToRef(result: Color4): void;
  11208. }
  11209. /** Class used to store color 3 gradient */
  11210. export class Color3Gradient implements IValueGradient {
  11211. /**
  11212. * Gets or sets the gradient value (between 0 and 1)
  11213. */
  11214. gradient: number;
  11215. /**
  11216. * Gets or sets the associated color
  11217. */
  11218. color: Color3;
  11219. /**
  11220. * Creates a new color3 gradient
  11221. * @param gradient gets or sets the gradient value (between 0 and 1)
  11222. * @param color gets or sets associated color
  11223. */
  11224. constructor(
  11225. /**
  11226. * Gets or sets the gradient value (between 0 and 1)
  11227. */
  11228. gradient: number,
  11229. /**
  11230. * Gets or sets the associated color
  11231. */
  11232. color: Color3);
  11233. }
  11234. /** Class used to store factor gradient */
  11235. export class FactorGradient implements IValueGradient {
  11236. /**
  11237. * Gets or sets the gradient value (between 0 and 1)
  11238. */
  11239. gradient: number;
  11240. /**
  11241. * Gets or sets first associated factor
  11242. */
  11243. factor1: number;
  11244. /**
  11245. * Gets or sets second associated factor
  11246. */
  11247. factor2?: number | undefined;
  11248. /**
  11249. * Creates a new factor gradient
  11250. * @param gradient gets or sets the gradient value (between 0 and 1)
  11251. * @param factor1 gets or sets first associated factor
  11252. * @param factor2 gets or sets second associated factor
  11253. */
  11254. constructor(
  11255. /**
  11256. * Gets or sets the gradient value (between 0 and 1)
  11257. */
  11258. gradient: number,
  11259. /**
  11260. * Gets or sets first associated factor
  11261. */
  11262. factor1: number,
  11263. /**
  11264. * Gets or sets second associated factor
  11265. */
  11266. factor2?: number | undefined);
  11267. /**
  11268. * Will get a number picked randomly between factor1 and factor2.
  11269. * If factor2 is undefined then factor1 will be used
  11270. * @returns the picked number
  11271. */
  11272. getFactor(): number;
  11273. }
  11274. /**
  11275. * Helper used to simplify some generic gradient tasks
  11276. */
  11277. export class GradientHelper {
  11278. /**
  11279. * Gets the current gradient from an array of IValueGradient
  11280. * @param ratio defines the current ratio to get
  11281. * @param gradients defines the array of IValueGradient
  11282. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11283. */
  11284. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11285. }
  11286. }
  11287. declare module BABYLON {
  11288. interface ThinEngine {
  11289. /**
  11290. * Creates a raw texture
  11291. * @param data defines the data to store in the texture
  11292. * @param width defines the width of the texture
  11293. * @param height defines the height of the texture
  11294. * @param format defines the format of the data
  11295. * @param generateMipMaps defines if the engine should generate the mip levels
  11296. * @param invertY defines if data must be stored with Y axis inverted
  11297. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11298. * @param compression defines the compression used (null by default)
  11299. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11300. * @returns the raw texture inside an InternalTexture
  11301. */
  11302. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11303. /**
  11304. * Update a raw texture
  11305. * @param texture defines the texture to update
  11306. * @param data defines the data to store in the texture
  11307. * @param format defines the format of the data
  11308. * @param invertY defines if data must be stored with Y axis inverted
  11309. */
  11310. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11311. /**
  11312. * Update a raw texture
  11313. * @param texture defines the texture to update
  11314. * @param data defines the data to store in the texture
  11315. * @param format defines the format of the data
  11316. * @param invertY defines if data must be stored with Y axis inverted
  11317. * @param compression defines the compression used (null by default)
  11318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11319. */
  11320. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11321. /**
  11322. * Creates a new raw cube texture
  11323. * @param data defines the array of data to use to create each face
  11324. * @param size defines the size of the textures
  11325. * @param format defines the format of the data
  11326. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11327. * @param generateMipMaps defines if the engine should generate the mip levels
  11328. * @param invertY defines if data must be stored with Y axis inverted
  11329. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11330. * @param compression defines the compression used (null by default)
  11331. * @returns the cube texture as an InternalTexture
  11332. */
  11333. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11334. /**
  11335. * Update a raw cube texture
  11336. * @param texture defines the texture to udpdate
  11337. * @param data defines the data to store
  11338. * @param format defines the data format
  11339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11340. * @param invertY defines if data must be stored with Y axis inverted
  11341. */
  11342. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11343. /**
  11344. * Update a raw cube texture
  11345. * @param texture defines the texture to udpdate
  11346. * @param data defines the data to store
  11347. * @param format defines the data format
  11348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11349. * @param invertY defines if data must be stored with Y axis inverted
  11350. * @param compression defines the compression used (null by default)
  11351. */
  11352. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11353. /**
  11354. * Update a raw cube texture
  11355. * @param texture defines the texture to udpdate
  11356. * @param data defines the data to store
  11357. * @param format defines the data format
  11358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11359. * @param invertY defines if data must be stored with Y axis inverted
  11360. * @param compression defines the compression used (null by default)
  11361. * @param level defines which level of the texture to update
  11362. */
  11363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11364. /**
  11365. * Creates a new raw cube texture from a specified url
  11366. * @param url defines the url where the data is located
  11367. * @param scene defines the current scene
  11368. * @param size defines the size of the textures
  11369. * @param format defines the format of the data
  11370. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11371. * @param noMipmap defines if the engine should avoid generating the mip levels
  11372. * @param callback defines a callback used to extract texture data from loaded data
  11373. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11374. * @param onLoad defines a callback called when texture is loaded
  11375. * @param onError defines a callback called if there is an error
  11376. * @returns the cube texture as an InternalTexture
  11377. */
  11378. 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;
  11379. /**
  11380. * Creates a new raw cube texture from a specified url
  11381. * @param url defines the url where the data is located
  11382. * @param scene defines the current scene
  11383. * @param size defines the size of the textures
  11384. * @param format defines the format of the data
  11385. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11386. * @param noMipmap defines if the engine should avoid generating the mip levels
  11387. * @param callback defines a callback used to extract texture data from loaded data
  11388. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11389. * @param onLoad defines a callback called when texture is loaded
  11390. * @param onError defines a callback called if there is an error
  11391. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11392. * @param invertY defines if data must be stored with Y axis inverted
  11393. * @returns the cube texture as an InternalTexture
  11394. */
  11395. 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;
  11396. /**
  11397. * Creates a new raw 3D texture
  11398. * @param data defines the data used to create the texture
  11399. * @param width defines the width of the texture
  11400. * @param height defines the height of the texture
  11401. * @param depth defines the depth of the texture
  11402. * @param format defines the format of the texture
  11403. * @param generateMipMaps defines if the engine must generate mip levels
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11406. * @param compression defines the compressed used (can be null)
  11407. * @param textureType defines the compressed used (can be null)
  11408. * @returns a new raw 3D texture (stored in an InternalTexture)
  11409. */
  11410. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11411. /**
  11412. * Update a raw 3D texture
  11413. * @param texture defines the texture to update
  11414. * @param data defines the data to store
  11415. * @param format defines the data format
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. */
  11418. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11419. /**
  11420. * Update a raw 3D texture
  11421. * @param texture defines the texture to update
  11422. * @param data defines the data to store
  11423. * @param format defines the data format
  11424. * @param invertY defines if data must be stored with Y axis inverted
  11425. * @param compression defines the used compression (can be null)
  11426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11427. */
  11428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11429. /**
  11430. * Creates a new raw 2D array texture
  11431. * @param data defines the data used to create the texture
  11432. * @param width defines the width of the texture
  11433. * @param height defines the height of the texture
  11434. * @param depth defines the number of layers of the texture
  11435. * @param format defines the format of the texture
  11436. * @param generateMipMaps defines if the engine must generate mip levels
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11439. * @param compression defines the compressed used (can be null)
  11440. * @param textureType defines the compressed used (can be null)
  11441. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11442. */
  11443. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11444. /**
  11445. * Update a raw 2D array texture
  11446. * @param texture defines the texture to update
  11447. * @param data defines the data to store
  11448. * @param format defines the data format
  11449. * @param invertY defines if data must be stored with Y axis inverted
  11450. */
  11451. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11452. /**
  11453. * Update a raw 2D array texture
  11454. * @param texture defines the texture to update
  11455. * @param data defines the data to store
  11456. * @param format defines the data format
  11457. * @param invertY defines if data must be stored with Y axis inverted
  11458. * @param compression defines the used compression (can be null)
  11459. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11460. */
  11461. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11462. }
  11463. }
  11464. declare module BABYLON {
  11465. /**
  11466. * Raw texture can help creating a texture directly from an array of data.
  11467. * This can be super useful if you either get the data from an uncompressed source or
  11468. * if you wish to create your texture pixel by pixel.
  11469. */
  11470. export class RawTexture extends Texture {
  11471. /**
  11472. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11473. */
  11474. format: number;
  11475. /**
  11476. * Instantiates a new RawTexture.
  11477. * Raw texture can help creating a texture directly from an array of data.
  11478. * This can be super useful if you either get the data from an uncompressed source or
  11479. * if you wish to create your texture pixel by pixel.
  11480. * @param data define the array of data to use to create the texture
  11481. * @param width define the width of the texture
  11482. * @param height define the height of the texture
  11483. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11484. * @param scene define the scene the texture belongs to
  11485. * @param generateMipMaps define whether mip maps should be generated or not
  11486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11488. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11489. */
  11490. constructor(data: ArrayBufferView, width: number, height: number,
  11491. /**
  11492. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11493. */
  11494. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11495. /**
  11496. * Updates the texture underlying data.
  11497. * @param data Define the new data of the texture
  11498. */
  11499. update(data: ArrayBufferView): void;
  11500. /**
  11501. * Creates a luminance texture from some data.
  11502. * @param data Define the texture data
  11503. * @param width Define the width of the texture
  11504. * @param height Define the height of the texture
  11505. * @param scene Define the scene the texture belongs to
  11506. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11507. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11508. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11509. * @returns the luminance texture
  11510. */
  11511. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11512. /**
  11513. * Creates a luminance alpha texture from some data.
  11514. * @param data Define the texture data
  11515. * @param width Define the width of the texture
  11516. * @param height Define the height of the texture
  11517. * @param scene Define the scene the texture belongs to
  11518. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11519. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11520. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11521. * @returns the luminance alpha texture
  11522. */
  11523. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11524. /**
  11525. * Creates an alpha texture from some data.
  11526. * @param data Define the texture data
  11527. * @param width Define the width of the texture
  11528. * @param height Define the height of the texture
  11529. * @param scene Define the scene the texture belongs to
  11530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11533. * @returns the alpha texture
  11534. */
  11535. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11536. /**
  11537. * Creates a RGB texture from some data.
  11538. * @param data Define the texture data
  11539. * @param width Define the width of the texture
  11540. * @param height Define the height of the texture
  11541. * @param scene Define the scene the texture belongs to
  11542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11545. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11546. * @returns the RGB alpha texture
  11547. */
  11548. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11549. /**
  11550. * Creates a RGBA texture from some data.
  11551. * @param data Define the texture data
  11552. * @param width Define the width of the texture
  11553. * @param height Define the height of the texture
  11554. * @param scene Define the scene the texture belongs to
  11555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11558. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11559. * @returns the RGBA texture
  11560. */
  11561. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11562. /**
  11563. * Creates a R texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param scene Define the scene the texture belongs to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the R texture
  11573. */
  11574. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. }
  11576. }
  11577. declare module BABYLON {
  11578. interface AbstractScene {
  11579. /**
  11580. * The list of procedural textures added to the scene
  11581. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11582. */
  11583. proceduralTextures: Array<ProceduralTexture>;
  11584. }
  11585. /**
  11586. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11587. * in a given scene.
  11588. */
  11589. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11590. /**
  11591. * The component name helpfull to identify the component in the list of scene components.
  11592. */
  11593. readonly name: string;
  11594. /**
  11595. * The scene the component belongs to.
  11596. */
  11597. scene: Scene;
  11598. /**
  11599. * Creates a new instance of the component for the given scene
  11600. * @param scene Defines the scene to register the component in
  11601. */
  11602. constructor(scene: Scene);
  11603. /**
  11604. * Registers the component in a given scene
  11605. */
  11606. register(): void;
  11607. /**
  11608. * Rebuilds the elements related to this component in case of
  11609. * context lost for instance.
  11610. */
  11611. rebuild(): void;
  11612. /**
  11613. * Disposes the component and the associated ressources.
  11614. */
  11615. dispose(): void;
  11616. private _beforeClear;
  11617. }
  11618. }
  11619. declare module BABYLON {
  11620. interface ThinEngine {
  11621. /**
  11622. * Creates a new render target cube texture
  11623. * @param size defines the size of the texture
  11624. * @param options defines the options used to create the texture
  11625. * @returns a new render target cube texture stored in an InternalTexture
  11626. */
  11627. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /** @hidden */
  11632. export var proceduralVertexShader: {
  11633. name: string;
  11634. shader: string;
  11635. };
  11636. }
  11637. declare module BABYLON {
  11638. /**
  11639. * 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.
  11640. * This is the base class of any Procedural texture and contains most of the shareable code.
  11641. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11642. */
  11643. export class ProceduralTexture extends Texture {
  11644. isCube: boolean;
  11645. /**
  11646. * Define if the texture is enabled or not (disabled texture will not render)
  11647. */
  11648. isEnabled: boolean;
  11649. /**
  11650. * Define if the texture must be cleared before rendering (default is true)
  11651. */
  11652. autoClear: boolean;
  11653. /**
  11654. * Callback called when the texture is generated
  11655. */
  11656. onGenerated: () => void;
  11657. /**
  11658. * Event raised when the texture is generated
  11659. */
  11660. onGeneratedObservable: Observable<ProceduralTexture>;
  11661. /** @hidden */
  11662. _generateMipMaps: boolean;
  11663. /** @hidden **/
  11664. _effect: Effect;
  11665. /** @hidden */
  11666. _textures: {
  11667. [key: string]: Texture;
  11668. };
  11669. /** @hidden */
  11670. protected _fallbackTexture: Nullable<Texture>;
  11671. private _size;
  11672. private _currentRefreshId;
  11673. private _frameId;
  11674. private _refreshRate;
  11675. private _vertexBuffers;
  11676. private _indexBuffer;
  11677. private _uniforms;
  11678. private _samplers;
  11679. private _fragment;
  11680. private _floats;
  11681. private _ints;
  11682. private _floatsArrays;
  11683. private _colors3;
  11684. private _colors4;
  11685. private _vectors2;
  11686. private _vectors3;
  11687. private _matrices;
  11688. private _fallbackTextureUsed;
  11689. private _fullEngine;
  11690. private _cachedDefines;
  11691. private _contentUpdateId;
  11692. private _contentData;
  11693. /**
  11694. * Instantiates a new procedural texture.
  11695. * 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.
  11696. * This is the base class of any Procedural texture and contains most of the shareable code.
  11697. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11698. * @param name Define the name of the texture
  11699. * @param size Define the size of the texture to create
  11700. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11701. * @param scene Define the scene the texture belongs to
  11702. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11703. * @param generateMipMaps Define if the texture should creates mip maps or not
  11704. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11705. */
  11706. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11707. /**
  11708. * The effect that is created when initializing the post process.
  11709. * @returns The created effect corresponding the the postprocess.
  11710. */
  11711. getEffect(): Effect;
  11712. /**
  11713. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11714. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11715. */
  11716. getContent(): Nullable<ArrayBufferView>;
  11717. private _createIndexBuffer;
  11718. /** @hidden */
  11719. _rebuild(): void;
  11720. /**
  11721. * Resets the texture in order to recreate its associated resources.
  11722. * This can be called in case of context loss
  11723. */
  11724. reset(): void;
  11725. protected _getDefines(): string;
  11726. /**
  11727. * Is the texture ready to be used ? (rendered at least once)
  11728. * @returns true if ready, otherwise, false.
  11729. */
  11730. isReady(): boolean;
  11731. /**
  11732. * Resets the refresh counter of the texture and start bak from scratch.
  11733. * Could be useful to regenerate the texture if it is setup to render only once.
  11734. */
  11735. resetRefreshCounter(): void;
  11736. /**
  11737. * Set the fragment shader to use in order to render the texture.
  11738. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11739. */
  11740. setFragment(fragment: any): void;
  11741. /**
  11742. * Define the refresh rate of the texture or the rendering frequency.
  11743. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11744. */
  11745. get refreshRate(): number;
  11746. set refreshRate(value: number);
  11747. /** @hidden */
  11748. _shouldRender(): boolean;
  11749. /**
  11750. * Get the size the texture is rendering at.
  11751. * @returns the size (texture is always squared)
  11752. */
  11753. getRenderSize(): number;
  11754. /**
  11755. * Resize the texture to new value.
  11756. * @param size Define the new size the texture should have
  11757. * @param generateMipMaps Define whether the new texture should create mip maps
  11758. */
  11759. resize(size: number, generateMipMaps: boolean): void;
  11760. private _checkUniform;
  11761. /**
  11762. * Set a texture in the shader program used to render.
  11763. * @param name Define the name of the uniform samplers as defined in the shader
  11764. * @param texture Define the texture to bind to this sampler
  11765. * @return the texture itself allowing "fluent" like uniform updates
  11766. */
  11767. setTexture(name: string, texture: Texture): ProceduralTexture;
  11768. /**
  11769. * Set a float in the shader.
  11770. * @param name Define the name of the uniform as defined in the shader
  11771. * @param value Define the value to give to the uniform
  11772. * @return the texture itself allowing "fluent" like uniform updates
  11773. */
  11774. setFloat(name: string, value: number): ProceduralTexture;
  11775. /**
  11776. * Set a int in the shader.
  11777. * @param name Define the name of the uniform as defined in the shader
  11778. * @param value Define the value to give to the uniform
  11779. * @return the texture itself allowing "fluent" like uniform updates
  11780. */
  11781. setInt(name: string, value: number): ProceduralTexture;
  11782. /**
  11783. * Set an array of floats in the shader.
  11784. * @param name Define the name of the uniform as defined in the shader
  11785. * @param value Define the value to give to the uniform
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setFloats(name: string, value: number[]): ProceduralTexture;
  11789. /**
  11790. * Set a vec3 in the shader from a Color3.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setColor3(name: string, value: Color3): ProceduralTexture;
  11796. /**
  11797. * Set a vec4 in the shader from a Color4.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setColor4(name: string, value: Color4): ProceduralTexture;
  11803. /**
  11804. * Set a vec2 in the shader from a Vector2.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setVector2(name: string, value: Vector2): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Vector3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setVector3(name: string, value: Vector3): ProceduralTexture;
  11817. /**
  11818. * Set a mat4 in the shader from a MAtrix.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11824. /**
  11825. * Render the texture to its associated render target.
  11826. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11827. */
  11828. render(useCameraPostProcess?: boolean): void;
  11829. /**
  11830. * Clone the texture.
  11831. * @returns the cloned texture
  11832. */
  11833. clone(): ProceduralTexture;
  11834. /**
  11835. * Dispose the texture and release its asoociated resources.
  11836. */
  11837. dispose(): void;
  11838. }
  11839. }
  11840. declare module BABYLON {
  11841. /**
  11842. * This represents the base class for particle system in Babylon.
  11843. * 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.
  11844. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11845. * @example https://doc.babylonjs.com/babylon101/particles
  11846. */
  11847. export class BaseParticleSystem {
  11848. /**
  11849. * Source color is added to the destination color without alpha affecting the result
  11850. */
  11851. static BLENDMODE_ONEONE: number;
  11852. /**
  11853. * Blend current color and particle color using particle’s alpha
  11854. */
  11855. static BLENDMODE_STANDARD: number;
  11856. /**
  11857. * Add current color and particle color multiplied by particle’s alpha
  11858. */
  11859. static BLENDMODE_ADD: number;
  11860. /**
  11861. * Multiply current color with particle color
  11862. */
  11863. static BLENDMODE_MULTIPLY: number;
  11864. /**
  11865. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11866. */
  11867. static BLENDMODE_MULTIPLYADD: number;
  11868. /**
  11869. * List of animations used by the particle system.
  11870. */
  11871. animations: Animation[];
  11872. /**
  11873. * Gets or sets the unique id of the particle system
  11874. */
  11875. uniqueId: number;
  11876. /**
  11877. * The id of the Particle system.
  11878. */
  11879. id: string;
  11880. /**
  11881. * The friendly name of the Particle system.
  11882. */
  11883. name: string;
  11884. /**
  11885. * Snippet ID if the particle system was created from the snippet server
  11886. */
  11887. snippetId: string;
  11888. /**
  11889. * The rendering group used by the Particle system to chose when to render.
  11890. */
  11891. renderingGroupId: number;
  11892. /**
  11893. * The emitter represents the Mesh or position we are attaching the particle system to.
  11894. */
  11895. emitter: Nullable<AbstractMesh | Vector3>;
  11896. /**
  11897. * The maximum number of particles to emit per frame
  11898. */
  11899. emitRate: number;
  11900. /**
  11901. * If you want to launch only a few particles at once, that can be done, as well.
  11902. */
  11903. manualEmitCount: number;
  11904. /**
  11905. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11906. */
  11907. updateSpeed: number;
  11908. /**
  11909. * The amount of time the particle system is running (depends of the overall update speed).
  11910. */
  11911. targetStopDuration: number;
  11912. /**
  11913. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11914. */
  11915. disposeOnStop: boolean;
  11916. /**
  11917. * Minimum power of emitting particles.
  11918. */
  11919. minEmitPower: number;
  11920. /**
  11921. * Maximum power of emitting particles.
  11922. */
  11923. maxEmitPower: number;
  11924. /**
  11925. * Minimum life time of emitting particles.
  11926. */
  11927. minLifeTime: number;
  11928. /**
  11929. * Maximum life time of emitting particles.
  11930. */
  11931. maxLifeTime: number;
  11932. /**
  11933. * Minimum Size of emitting particles.
  11934. */
  11935. minSize: number;
  11936. /**
  11937. * Maximum Size of emitting particles.
  11938. */
  11939. maxSize: number;
  11940. /**
  11941. * Minimum scale of emitting particles on X axis.
  11942. */
  11943. minScaleX: number;
  11944. /**
  11945. * Maximum scale of emitting particles on X axis.
  11946. */
  11947. maxScaleX: number;
  11948. /**
  11949. * Minimum scale of emitting particles on Y axis.
  11950. */
  11951. minScaleY: number;
  11952. /**
  11953. * Maximum scale of emitting particles on Y axis.
  11954. */
  11955. maxScaleY: number;
  11956. /**
  11957. * Gets or sets the minimal initial rotation in radians.
  11958. */
  11959. minInitialRotation: number;
  11960. /**
  11961. * Gets or sets the maximal initial rotation in radians.
  11962. */
  11963. maxInitialRotation: number;
  11964. /**
  11965. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11966. */
  11967. minAngularSpeed: number;
  11968. /**
  11969. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11970. */
  11971. maxAngularSpeed: number;
  11972. /**
  11973. * The texture used to render each particle. (this can be a spritesheet)
  11974. */
  11975. particleTexture: Nullable<Texture>;
  11976. /**
  11977. * The layer mask we are rendering the particles through.
  11978. */
  11979. layerMask: number;
  11980. /**
  11981. * This can help using your own shader to render the particle system.
  11982. * The according effect will be created
  11983. */
  11984. customShader: any;
  11985. /**
  11986. * By default particle system starts as soon as they are created. This prevents the
  11987. * automatic start to happen and let you decide when to start emitting particles.
  11988. */
  11989. preventAutoStart: boolean;
  11990. private _noiseTexture;
  11991. /**
  11992. * Gets or sets a texture used to add random noise to particle positions
  11993. */
  11994. get noiseTexture(): Nullable<ProceduralTexture>;
  11995. set noiseTexture(value: Nullable<ProceduralTexture>);
  11996. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11997. noiseStrength: Vector3;
  11998. /**
  11999. * Callback triggered when the particle animation is ending.
  12000. */
  12001. onAnimationEnd: Nullable<() => void>;
  12002. /**
  12003. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12004. */
  12005. blendMode: number;
  12006. /**
  12007. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12008. * to override the particles.
  12009. */
  12010. forceDepthWrite: boolean;
  12011. /** 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 */
  12012. preWarmCycles: number;
  12013. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12014. preWarmStepOffset: number;
  12015. /**
  12016. * 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)
  12017. */
  12018. spriteCellChangeSpeed: number;
  12019. /**
  12020. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12021. */
  12022. startSpriteCellID: number;
  12023. /**
  12024. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12025. */
  12026. endSpriteCellID: number;
  12027. /**
  12028. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12029. */
  12030. spriteCellWidth: number;
  12031. /**
  12032. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12033. */
  12034. spriteCellHeight: number;
  12035. /**
  12036. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12037. */
  12038. spriteRandomStartCell: boolean;
  12039. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12040. translationPivot: Vector2;
  12041. /** @hidden */
  12042. protected _isAnimationSheetEnabled: boolean;
  12043. /**
  12044. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12045. */
  12046. beginAnimationOnStart: boolean;
  12047. /**
  12048. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12049. */
  12050. beginAnimationFrom: number;
  12051. /**
  12052. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12053. */
  12054. beginAnimationTo: number;
  12055. /**
  12056. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12057. */
  12058. beginAnimationLoop: boolean;
  12059. /**
  12060. * Gets or sets a world offset applied to all particles
  12061. */
  12062. worldOffset: Vector3;
  12063. /**
  12064. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12065. */
  12066. get isAnimationSheetEnabled(): boolean;
  12067. set isAnimationSheetEnabled(value: boolean);
  12068. /**
  12069. * Get hosting scene
  12070. * @returns the scene
  12071. */
  12072. getScene(): Scene;
  12073. /**
  12074. * You can use gravity if you want to give an orientation to your particles.
  12075. */
  12076. gravity: Vector3;
  12077. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12078. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12079. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12080. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12081. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12082. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12083. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12084. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12085. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12086. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12087. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12088. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12089. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12090. /**
  12091. * Defines the delay in milliseconds before starting the system (0 by default)
  12092. */
  12093. startDelay: number;
  12094. /**
  12095. * Gets the current list of drag gradients.
  12096. * You must use addDragGradient and removeDragGradient to udpate this list
  12097. * @returns the list of drag gradients
  12098. */
  12099. getDragGradients(): Nullable<Array<FactorGradient>>;
  12100. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12101. limitVelocityDamping: number;
  12102. /**
  12103. * Gets the current list of limit velocity gradients.
  12104. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12105. * @returns the list of limit velocity gradients
  12106. */
  12107. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12108. /**
  12109. * Gets the current list of color gradients.
  12110. * You must use addColorGradient and removeColorGradient to udpate this list
  12111. * @returns the list of color gradients
  12112. */
  12113. getColorGradients(): Nullable<Array<ColorGradient>>;
  12114. /**
  12115. * Gets the current list of size gradients.
  12116. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12117. * @returns the list of size gradients
  12118. */
  12119. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12120. /**
  12121. * Gets the current list of color remap gradients.
  12122. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12123. * @returns the list of color remap gradients
  12124. */
  12125. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12126. /**
  12127. * Gets the current list of alpha remap gradients.
  12128. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12129. * @returns the list of alpha remap gradients
  12130. */
  12131. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12132. /**
  12133. * Gets the current list of life time gradients.
  12134. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12135. * @returns the list of life time gradients
  12136. */
  12137. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12138. /**
  12139. * Gets the current list of angular speed gradients.
  12140. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12141. * @returns the list of angular speed gradients
  12142. */
  12143. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12144. /**
  12145. * Gets the current list of velocity gradients.
  12146. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12147. * @returns the list of velocity gradients
  12148. */
  12149. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12150. /**
  12151. * Gets the current list of start size gradients.
  12152. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12153. * @returns the list of start size gradients
  12154. */
  12155. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12156. /**
  12157. * Gets the current list of emit rate gradients.
  12158. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12159. * @returns the list of emit rate gradients
  12160. */
  12161. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12162. /**
  12163. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12164. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12165. */
  12166. get direction1(): Vector3;
  12167. set direction1(value: Vector3);
  12168. /**
  12169. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12170. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12171. */
  12172. get direction2(): Vector3;
  12173. set direction2(value: Vector3);
  12174. /**
  12175. * 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.
  12176. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12177. */
  12178. get minEmitBox(): Vector3;
  12179. set minEmitBox(value: Vector3);
  12180. /**
  12181. * 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.
  12182. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12183. */
  12184. get maxEmitBox(): Vector3;
  12185. set maxEmitBox(value: Vector3);
  12186. /**
  12187. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12188. */
  12189. color1: Color4;
  12190. /**
  12191. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12192. */
  12193. color2: Color4;
  12194. /**
  12195. * Color the particle will have at the end of its lifetime
  12196. */
  12197. colorDead: Color4;
  12198. /**
  12199. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12200. */
  12201. textureMask: Color4;
  12202. /**
  12203. * The particle emitter type defines the emitter used by the particle system.
  12204. * It can be for example box, sphere, or cone...
  12205. */
  12206. particleEmitterType: IParticleEmitterType;
  12207. /** @hidden */
  12208. _isSubEmitter: boolean;
  12209. /**
  12210. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12211. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12212. */
  12213. billboardMode: number;
  12214. protected _isBillboardBased: boolean;
  12215. /**
  12216. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12217. */
  12218. get isBillboardBased(): boolean;
  12219. set isBillboardBased(value: boolean);
  12220. /**
  12221. * The scene the particle system belongs to.
  12222. */
  12223. protected _scene: Scene;
  12224. /**
  12225. * Local cache of defines for image processing.
  12226. */
  12227. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12228. /**
  12229. * Default configuration related to image processing available in the standard Material.
  12230. */
  12231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12232. /**
  12233. * Gets the image processing configuration used either in this material.
  12234. */
  12235. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12236. /**
  12237. * Sets the Default image processing configuration used either in the this material.
  12238. *
  12239. * If sets to null, the scene one is in use.
  12240. */
  12241. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12242. /**
  12243. * Attaches a new image processing configuration to the Standard Material.
  12244. * @param configuration
  12245. */
  12246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12247. /** @hidden */
  12248. protected _reset(): void;
  12249. /** @hidden */
  12250. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12251. /**
  12252. * Instantiates a particle system.
  12253. * 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.
  12254. * @param name The name of the particle system
  12255. */
  12256. constructor(name: string);
  12257. /**
  12258. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12259. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12260. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12261. * @returns the emitter
  12262. */
  12263. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12264. /**
  12265. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12266. * @param radius The radius of the hemisphere to emit from
  12267. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12268. * @returns the emitter
  12269. */
  12270. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12271. /**
  12272. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12273. * @param radius The radius of the sphere to emit from
  12274. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12275. * @returns the emitter
  12276. */
  12277. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12278. /**
  12279. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12280. * @param radius The radius of the sphere to emit from
  12281. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12282. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12283. * @returns the emitter
  12284. */
  12285. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12286. /**
  12287. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12288. * @param radius The radius of the emission cylinder
  12289. * @param height The height of the emission cylinder
  12290. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12291. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12292. * @returns the emitter
  12293. */
  12294. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12295. /**
  12296. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12297. * @param radius The radius of the cylinder to emit from
  12298. * @param height The height of the emission cylinder
  12299. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12300. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12301. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12302. * @returns the emitter
  12303. */
  12304. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12305. /**
  12306. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12307. * @param radius The radius of the cone to emit from
  12308. * @param angle The base angle of the cone
  12309. * @returns the emitter
  12310. */
  12311. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12312. /**
  12313. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12316. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12317. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12318. * @returns the emitter
  12319. */
  12320. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12321. }
  12322. }
  12323. declare module BABYLON {
  12324. /**
  12325. * Type of sub emitter
  12326. */
  12327. export enum SubEmitterType {
  12328. /**
  12329. * Attached to the particle over it's lifetime
  12330. */
  12331. ATTACHED = 0,
  12332. /**
  12333. * Created when the particle dies
  12334. */
  12335. END = 1
  12336. }
  12337. /**
  12338. * Sub emitter class used to emit particles from an existing particle
  12339. */
  12340. export class SubEmitter {
  12341. /**
  12342. * the particle system to be used by the sub emitter
  12343. */
  12344. particleSystem: ParticleSystem;
  12345. /**
  12346. * Type of the submitter (Default: END)
  12347. */
  12348. type: SubEmitterType;
  12349. /**
  12350. * 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)
  12351. * Note: This only is supported when using an emitter of type Mesh
  12352. */
  12353. inheritDirection: boolean;
  12354. /**
  12355. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12356. */
  12357. inheritedVelocityAmount: number;
  12358. /**
  12359. * Creates a sub emitter
  12360. * @param particleSystem the particle system to be used by the sub emitter
  12361. */
  12362. constructor(
  12363. /**
  12364. * the particle system to be used by the sub emitter
  12365. */
  12366. particleSystem: ParticleSystem);
  12367. /**
  12368. * Clones the sub emitter
  12369. * @returns the cloned sub emitter
  12370. */
  12371. clone(): SubEmitter;
  12372. /**
  12373. * Serialize current object to a JSON object
  12374. * @returns the serialized object
  12375. */
  12376. serialize(): any;
  12377. /** @hidden */
  12378. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12379. /**
  12380. * Creates a new SubEmitter from a serialized JSON version
  12381. * @param serializationObject defines the JSON object to read from
  12382. * @param scene defines the hosting scene
  12383. * @param rootUrl defines the rootUrl for data loading
  12384. * @returns a new SubEmitter
  12385. */
  12386. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12387. /** Release associated resources */
  12388. dispose(): void;
  12389. }
  12390. }
  12391. declare module BABYLON {
  12392. /** @hidden */
  12393. export var imageProcessingDeclaration: {
  12394. name: string;
  12395. shader: string;
  12396. };
  12397. }
  12398. declare module BABYLON {
  12399. /** @hidden */
  12400. export var imageProcessingFunctions: {
  12401. name: string;
  12402. shader: string;
  12403. };
  12404. }
  12405. declare module BABYLON {
  12406. /** @hidden */
  12407. export var particlesPixelShader: {
  12408. name: string;
  12409. shader: string;
  12410. };
  12411. }
  12412. declare module BABYLON {
  12413. /** @hidden */
  12414. export var particlesVertexShader: {
  12415. name: string;
  12416. shader: string;
  12417. };
  12418. }
  12419. declare module BABYLON {
  12420. /**
  12421. * This represents a particle system in Babylon.
  12422. * 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.
  12423. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12424. * @example https://doc.babylonjs.com/babylon101/particles
  12425. */
  12426. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12427. /**
  12428. * Billboard mode will only apply to Y axis
  12429. */
  12430. static readonly BILLBOARDMODE_Y: number;
  12431. /**
  12432. * Billboard mode will apply to all axes
  12433. */
  12434. static readonly BILLBOARDMODE_ALL: number;
  12435. /**
  12436. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12437. */
  12438. static readonly BILLBOARDMODE_STRETCHED: number;
  12439. /**
  12440. * This function can be defined to provide custom update for active particles.
  12441. * This function will be called instead of regular update (age, position, color, etc.).
  12442. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12443. */
  12444. updateFunction: (particles: Particle[]) => void;
  12445. private _emitterWorldMatrix;
  12446. /**
  12447. * This function can be defined to specify initial direction for every new particle.
  12448. * It by default use the emitterType defined function
  12449. */
  12450. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12451. /**
  12452. * This function can be defined to specify initial position for every new particle.
  12453. * It by default use the emitterType defined function
  12454. */
  12455. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12456. /**
  12457. * @hidden
  12458. */
  12459. _inheritedVelocityOffset: Vector3;
  12460. /**
  12461. * An event triggered when the system is disposed
  12462. */
  12463. onDisposeObservable: Observable<IParticleSystem>;
  12464. private _onDisposeObserver;
  12465. /**
  12466. * Sets a callback that will be triggered when the system is disposed
  12467. */
  12468. set onDispose(callback: () => void);
  12469. private _particles;
  12470. private _epsilon;
  12471. private _capacity;
  12472. private _stockParticles;
  12473. private _newPartsExcess;
  12474. private _vertexData;
  12475. private _vertexBuffer;
  12476. private _vertexBuffers;
  12477. private _spriteBuffer;
  12478. private _indexBuffer;
  12479. private _effect;
  12480. private _customEffect;
  12481. private _cachedDefines;
  12482. private _scaledColorStep;
  12483. private _colorDiff;
  12484. private _scaledDirection;
  12485. private _scaledGravity;
  12486. private _currentRenderId;
  12487. private _alive;
  12488. private _useInstancing;
  12489. private _started;
  12490. private _stopped;
  12491. private _actualFrame;
  12492. private _scaledUpdateSpeed;
  12493. private _vertexBufferSize;
  12494. /** @hidden */
  12495. _currentEmitRateGradient: Nullable<FactorGradient>;
  12496. /** @hidden */
  12497. _currentEmitRate1: number;
  12498. /** @hidden */
  12499. _currentEmitRate2: number;
  12500. /** @hidden */
  12501. _currentStartSizeGradient: Nullable<FactorGradient>;
  12502. /** @hidden */
  12503. _currentStartSize1: number;
  12504. /** @hidden */
  12505. _currentStartSize2: number;
  12506. private readonly _rawTextureWidth;
  12507. private _rampGradientsTexture;
  12508. private _useRampGradients;
  12509. /** Gets or sets a boolean indicating that ramp gradients must be used
  12510. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12511. */
  12512. get useRampGradients(): boolean;
  12513. set useRampGradients(value: boolean);
  12514. /**
  12515. * 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.
  12516. * 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: [])
  12517. */
  12518. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12519. private _subEmitters;
  12520. /**
  12521. * @hidden
  12522. * If the particle systems emitter should be disposed when the particle system is disposed
  12523. */
  12524. _disposeEmitterOnDispose: boolean;
  12525. /**
  12526. * The current active Sub-systems, this property is used by the root particle system only.
  12527. */
  12528. activeSubSystems: Array<ParticleSystem>;
  12529. /**
  12530. * Specifies if the particles are updated in emitter local space or world space
  12531. */
  12532. isLocal: boolean;
  12533. private _rootParticleSystem;
  12534. /**
  12535. * Gets the current list of active particles
  12536. */
  12537. get particles(): Particle[];
  12538. /**
  12539. * Gets the number of particles active at the same time.
  12540. * @returns The number of active particles.
  12541. */
  12542. getActiveCount(): number;
  12543. /**
  12544. * Returns the string "ParticleSystem"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Gets a boolean indicating that the system is stopping
  12550. * @returns true if the system is currently stopping
  12551. */
  12552. isStopping(): boolean;
  12553. /**
  12554. * Gets the custom effect used to render the particles
  12555. * @param blendMode Blend mode for which the effect should be retrieved
  12556. * @returns The effect
  12557. */
  12558. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12559. /**
  12560. * Sets the custom effect used to render the particles
  12561. * @param effect The effect to set
  12562. * @param blendMode Blend mode for which the effect should be set
  12563. */
  12564. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12565. /** @hidden */
  12566. private _onBeforeDrawParticlesObservable;
  12567. /**
  12568. * Observable that will be called just before the particles are drawn
  12569. */
  12570. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12571. /**
  12572. * Gets the name of the particle vertex shader
  12573. */
  12574. get vertexShaderName(): string;
  12575. /**
  12576. * Instantiates a particle system.
  12577. * 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.
  12578. * @param name The name of the particle system
  12579. * @param capacity The max number of particles alive at the same time
  12580. * @param scene The scene the particle system belongs to
  12581. * @param customEffect a custom effect used to change the way particles are rendered by default
  12582. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12583. * @param epsilon Offset used to render the particles
  12584. */
  12585. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12586. private _addFactorGradient;
  12587. private _removeFactorGradient;
  12588. /**
  12589. * Adds a new life time gradient
  12590. * @param gradient defines the gradient to use (between 0 and 1)
  12591. * @param factor defines the life time factor to affect to the specified gradient
  12592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12593. * @returns the current particle system
  12594. */
  12595. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12596. /**
  12597. * Remove a specific life time gradient
  12598. * @param gradient defines the gradient to remove
  12599. * @returns the current particle system
  12600. */
  12601. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12602. /**
  12603. * Adds a new size gradient
  12604. * @param gradient defines the gradient to use (between 0 and 1)
  12605. * @param factor defines the size factor to affect to the specified gradient
  12606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12607. * @returns the current particle system
  12608. */
  12609. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12610. /**
  12611. * Remove a specific size gradient
  12612. * @param gradient defines the gradient to remove
  12613. * @returns the current particle system
  12614. */
  12615. removeSizeGradient(gradient: number): IParticleSystem;
  12616. /**
  12617. * Adds a new color remap gradient
  12618. * @param gradient defines the gradient to use (between 0 and 1)
  12619. * @param min defines the color remap minimal range
  12620. * @param max defines the color remap maximal range
  12621. * @returns the current particle system
  12622. */
  12623. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12624. /**
  12625. * Remove a specific color remap gradient
  12626. * @param gradient defines the gradient to remove
  12627. * @returns the current particle system
  12628. */
  12629. removeColorRemapGradient(gradient: number): IParticleSystem;
  12630. /**
  12631. * Adds a new alpha remap gradient
  12632. * @param gradient defines the gradient to use (between 0 and 1)
  12633. * @param min defines the alpha remap minimal range
  12634. * @param max defines the alpha remap maximal range
  12635. * @returns the current particle system
  12636. */
  12637. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12638. /**
  12639. * Remove a specific alpha remap gradient
  12640. * @param gradient defines the gradient to remove
  12641. * @returns the current particle system
  12642. */
  12643. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12644. /**
  12645. * Adds a new angular speed gradient
  12646. * @param gradient defines the gradient to use (between 0 and 1)
  12647. * @param factor defines the angular speed to affect to the specified gradient
  12648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12649. * @returns the current particle system
  12650. */
  12651. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12652. /**
  12653. * Remove a specific angular speed gradient
  12654. * @param gradient defines the gradient to remove
  12655. * @returns the current particle system
  12656. */
  12657. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12658. /**
  12659. * Adds a new velocity gradient
  12660. * @param gradient defines the gradient to use (between 0 and 1)
  12661. * @param factor defines the velocity to affect to the specified gradient
  12662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12663. * @returns the current particle system
  12664. */
  12665. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12666. /**
  12667. * Remove a specific velocity gradient
  12668. * @param gradient defines the gradient to remove
  12669. * @returns the current particle system
  12670. */
  12671. removeVelocityGradient(gradient: number): IParticleSystem;
  12672. /**
  12673. * Adds a new limit velocity gradient
  12674. * @param gradient defines the gradient to use (between 0 and 1)
  12675. * @param factor defines the limit velocity value to affect to the specified gradient
  12676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12677. * @returns the current particle system
  12678. */
  12679. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12680. /**
  12681. * Remove a specific limit velocity gradient
  12682. * @param gradient defines the gradient to remove
  12683. * @returns the current particle system
  12684. */
  12685. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12686. /**
  12687. * Adds a new drag gradient
  12688. * @param gradient defines the gradient to use (between 0 and 1)
  12689. * @param factor defines the drag value to affect to the specified gradient
  12690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12691. * @returns the current particle system
  12692. */
  12693. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12694. /**
  12695. * Remove a specific drag gradient
  12696. * @param gradient defines the gradient to remove
  12697. * @returns the current particle system
  12698. */
  12699. removeDragGradient(gradient: number): IParticleSystem;
  12700. /**
  12701. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12702. * @param gradient defines the gradient to use (between 0 and 1)
  12703. * @param factor defines the emit rate value to affect to the specified gradient
  12704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12705. * @returns the current particle system
  12706. */
  12707. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12708. /**
  12709. * Remove a specific emit rate gradient
  12710. * @param gradient defines the gradient to remove
  12711. * @returns the current particle system
  12712. */
  12713. removeEmitRateGradient(gradient: number): IParticleSystem;
  12714. /**
  12715. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12716. * @param gradient defines the gradient to use (between 0 and 1)
  12717. * @param factor defines the start size value to affect to the specified gradient
  12718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12719. * @returns the current particle system
  12720. */
  12721. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12722. /**
  12723. * Remove a specific start size gradient
  12724. * @param gradient defines the gradient to remove
  12725. * @returns the current particle system
  12726. */
  12727. removeStartSizeGradient(gradient: number): IParticleSystem;
  12728. private _createRampGradientTexture;
  12729. /**
  12730. * Gets the current list of ramp gradients.
  12731. * You must use addRampGradient and removeRampGradient to udpate this list
  12732. * @returns the list of ramp gradients
  12733. */
  12734. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12735. /** Force the system to rebuild all gradients that need to be resync */
  12736. forceRefreshGradients(): void;
  12737. private _syncRampGradientTexture;
  12738. /**
  12739. * Adds a new ramp gradient used to remap particle colors
  12740. * @param gradient defines the gradient to use (between 0 and 1)
  12741. * @param color defines the color to affect to the specified gradient
  12742. * @returns the current particle system
  12743. */
  12744. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12745. /**
  12746. * Remove a specific ramp gradient
  12747. * @param gradient defines the gradient to remove
  12748. * @returns the current particle system
  12749. */
  12750. removeRampGradient(gradient: number): ParticleSystem;
  12751. /**
  12752. * Adds a new color gradient
  12753. * @param gradient defines the gradient to use (between 0 and 1)
  12754. * @param color1 defines the color to affect to the specified gradient
  12755. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12756. * @returns this particle system
  12757. */
  12758. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12759. /**
  12760. * Remove a specific color gradient
  12761. * @param gradient defines the gradient to remove
  12762. * @returns this particle system
  12763. */
  12764. removeColorGradient(gradient: number): IParticleSystem;
  12765. private _fetchR;
  12766. protected _reset(): void;
  12767. private _resetEffect;
  12768. private _createVertexBuffers;
  12769. private _createIndexBuffer;
  12770. /**
  12771. * Gets the maximum number of particles active at the same time.
  12772. * @returns The max number of active particles.
  12773. */
  12774. getCapacity(): number;
  12775. /**
  12776. * Gets whether there are still active particles in the system.
  12777. * @returns True if it is alive, otherwise false.
  12778. */
  12779. isAlive(): boolean;
  12780. /**
  12781. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12782. * @returns True if it has been started, otherwise false.
  12783. */
  12784. isStarted(): boolean;
  12785. private _prepareSubEmitterInternalArray;
  12786. /**
  12787. * Starts the particle system and begins to emit
  12788. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12789. */
  12790. start(delay?: number): void;
  12791. /**
  12792. * Stops the particle system.
  12793. * @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.
  12794. */
  12795. stop(stopSubEmitters?: boolean): void;
  12796. /**
  12797. * Remove all active particles
  12798. */
  12799. reset(): void;
  12800. /**
  12801. * @hidden (for internal use only)
  12802. */
  12803. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12804. /**
  12805. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12806. * Its lifetime will start back at 0.
  12807. */
  12808. recycleParticle: (particle: Particle) => void;
  12809. private _stopSubEmitters;
  12810. private _createParticle;
  12811. private _removeFromRoot;
  12812. private _emitFromParticle;
  12813. private _update;
  12814. /** @hidden */
  12815. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12816. /** @hidden */
  12817. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12818. /**
  12819. * Fill the defines array according to the current settings of the particle system
  12820. * @param defines Array to be updated
  12821. * @param blendMode blend mode to take into account when updating the array
  12822. */
  12823. fillDefines(defines: Array<string>, blendMode: number): void;
  12824. /**
  12825. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12826. * @param uniforms Uniforms array to fill
  12827. * @param attributes Attributes array to fill
  12828. * @param samplers Samplers array to fill
  12829. */
  12830. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12831. /** @hidden */
  12832. private _getEffect;
  12833. /**
  12834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12835. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12836. */
  12837. animate(preWarmOnly?: boolean): void;
  12838. private _appendParticleVertices;
  12839. /**
  12840. * Rebuilds the particle system.
  12841. */
  12842. rebuild(): void;
  12843. /**
  12844. * Is this system ready to be used/rendered
  12845. * @return true if the system is ready
  12846. */
  12847. isReady(): boolean;
  12848. private _render;
  12849. /**
  12850. * Renders the particle system in its current state.
  12851. * @returns the current number of particles
  12852. */
  12853. render(): number;
  12854. /**
  12855. * Disposes the particle system and free the associated resources
  12856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12857. */
  12858. dispose(disposeTexture?: boolean): void;
  12859. /**
  12860. * Clones the particle system.
  12861. * @param name The name of the cloned object
  12862. * @param newEmitter The new emitter to use
  12863. * @returns the cloned particle system
  12864. */
  12865. clone(name: string, newEmitter: any): ParticleSystem;
  12866. /**
  12867. * Serializes the particle system to a JSON object
  12868. * @param serializeTexture defines if the texture must be serialized as well
  12869. * @returns the JSON object
  12870. */
  12871. serialize(serializeTexture?: boolean): any;
  12872. /** @hidden */
  12873. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12874. /** @hidden */
  12875. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12876. /**
  12877. * Parses a JSON object to create a particle system.
  12878. * @param parsedParticleSystem The JSON object to parse
  12879. * @param scene The scene to create the particle system in
  12880. * @param rootUrl The root url to use to load external dependencies like texture
  12881. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12882. * @returns the Parsed particle system
  12883. */
  12884. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12885. }
  12886. }
  12887. declare module BABYLON {
  12888. /**
  12889. * A particle represents one of the element emitted by a particle system.
  12890. * This is mainly define by its coordinates, direction, velocity and age.
  12891. */
  12892. export class Particle {
  12893. /**
  12894. * The particle system the particle belongs to.
  12895. */
  12896. particleSystem: ParticleSystem;
  12897. private static _Count;
  12898. /**
  12899. * Unique ID of the particle
  12900. */
  12901. id: number;
  12902. /**
  12903. * The world position of the particle in the scene.
  12904. */
  12905. position: Vector3;
  12906. /**
  12907. * The world direction of the particle in the scene.
  12908. */
  12909. direction: Vector3;
  12910. /**
  12911. * The color of the particle.
  12912. */
  12913. color: Color4;
  12914. /**
  12915. * The color change of the particle per step.
  12916. */
  12917. colorStep: Color4;
  12918. /**
  12919. * Defines how long will the life of the particle be.
  12920. */
  12921. lifeTime: number;
  12922. /**
  12923. * The current age of the particle.
  12924. */
  12925. age: number;
  12926. /**
  12927. * The current size of the particle.
  12928. */
  12929. size: number;
  12930. /**
  12931. * The current scale of the particle.
  12932. */
  12933. scale: Vector2;
  12934. /**
  12935. * The current angle of the particle.
  12936. */
  12937. angle: number;
  12938. /**
  12939. * Defines how fast is the angle changing.
  12940. */
  12941. angularSpeed: number;
  12942. /**
  12943. * Defines the cell index used by the particle to be rendered from a sprite.
  12944. */
  12945. cellIndex: number;
  12946. /**
  12947. * The information required to support color remapping
  12948. */
  12949. remapData: Vector4;
  12950. /** @hidden */
  12951. _randomCellOffset?: number;
  12952. /** @hidden */
  12953. _initialDirection: Nullable<Vector3>;
  12954. /** @hidden */
  12955. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12956. /** @hidden */
  12957. _initialStartSpriteCellID: number;
  12958. /** @hidden */
  12959. _initialEndSpriteCellID: number;
  12960. /** @hidden */
  12961. _currentColorGradient: Nullable<ColorGradient>;
  12962. /** @hidden */
  12963. _currentColor1: Color4;
  12964. /** @hidden */
  12965. _currentColor2: Color4;
  12966. /** @hidden */
  12967. _currentSizeGradient: Nullable<FactorGradient>;
  12968. /** @hidden */
  12969. _currentSize1: number;
  12970. /** @hidden */
  12971. _currentSize2: number;
  12972. /** @hidden */
  12973. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12974. /** @hidden */
  12975. _currentAngularSpeed1: number;
  12976. /** @hidden */
  12977. _currentAngularSpeed2: number;
  12978. /** @hidden */
  12979. _currentVelocityGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentVelocity1: number;
  12982. /** @hidden */
  12983. _currentVelocity2: number;
  12984. /** @hidden */
  12985. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentLimitVelocity1: number;
  12988. /** @hidden */
  12989. _currentLimitVelocity2: number;
  12990. /** @hidden */
  12991. _currentDragGradient: Nullable<FactorGradient>;
  12992. /** @hidden */
  12993. _currentDrag1: number;
  12994. /** @hidden */
  12995. _currentDrag2: number;
  12996. /** @hidden */
  12997. _randomNoiseCoordinates1: Vector3;
  12998. /** @hidden */
  12999. _randomNoiseCoordinates2: Vector3;
  13000. /** @hidden */
  13001. _localPosition?: Vector3;
  13002. /**
  13003. * Creates a new instance Particle
  13004. * @param particleSystem the particle system the particle belongs to
  13005. */
  13006. constructor(
  13007. /**
  13008. * The particle system the particle belongs to.
  13009. */
  13010. particleSystem: ParticleSystem);
  13011. private updateCellInfoFromSystem;
  13012. /**
  13013. * Defines how the sprite cell index is updated for the particle
  13014. */
  13015. updateCellIndex(): void;
  13016. /** @hidden */
  13017. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13018. /** @hidden */
  13019. _inheritParticleInfoToSubEmitters(): void;
  13020. /** @hidden */
  13021. _reset(): void;
  13022. /**
  13023. * Copy the properties of particle to another one.
  13024. * @param other the particle to copy the information to.
  13025. */
  13026. copyTo(other: Particle): void;
  13027. }
  13028. }
  13029. declare module BABYLON {
  13030. /**
  13031. * Particle emitter represents a volume emitting particles.
  13032. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13033. */
  13034. export interface IParticleEmitterType {
  13035. /**
  13036. * Called by the particle System when the direction is computed for the created particle.
  13037. * @param worldMatrix is the world matrix of the particle system
  13038. * @param directionToUpdate is the direction vector to update with the result
  13039. * @param particle is the particle we are computed the direction for
  13040. * @param isLocal defines if the direction should be set in local space
  13041. */
  13042. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13043. /**
  13044. * Called by the particle System when the position is computed for the created particle.
  13045. * @param worldMatrix is the world matrix of the particle system
  13046. * @param positionToUpdate is the position vector to update with the result
  13047. * @param particle is the particle we are computed the position for
  13048. * @param isLocal defines if the position should be set in local space
  13049. */
  13050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13051. /**
  13052. * Clones the current emitter and returns a copy of it
  13053. * @returns the new emitter
  13054. */
  13055. clone(): IParticleEmitterType;
  13056. /**
  13057. * Called by the GPUParticleSystem to setup the update shader
  13058. * @param effect defines the update shader
  13059. */
  13060. applyToShader(effect: Effect): void;
  13061. /**
  13062. * Returns a string to use to update the GPU particles update shader
  13063. * @returns the effect defines string
  13064. */
  13065. getEffectDefines(): string;
  13066. /**
  13067. * Returns a string representing the class name
  13068. * @returns a string containing the class name
  13069. */
  13070. getClassName(): string;
  13071. /**
  13072. * Serializes the particle system to a JSON object.
  13073. * @returns the JSON object
  13074. */
  13075. serialize(): any;
  13076. /**
  13077. * Parse properties from a JSON object
  13078. * @param serializationObject defines the JSON object
  13079. * @param scene defines the hosting scene
  13080. */
  13081. parse(serializationObject: any, scene: Scene): void;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * Particle emitter emitting particles from the inside of a box.
  13087. * It emits the particles randomly between 2 given directions.
  13088. */
  13089. export class BoxParticleEmitter implements IParticleEmitterType {
  13090. /**
  13091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13092. */
  13093. direction1: Vector3;
  13094. /**
  13095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13096. */
  13097. direction2: Vector3;
  13098. /**
  13099. * 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.
  13100. */
  13101. minEmitBox: Vector3;
  13102. /**
  13103. * 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.
  13104. */
  13105. maxEmitBox: Vector3;
  13106. /**
  13107. * Creates a new instance BoxParticleEmitter
  13108. */
  13109. constructor();
  13110. /**
  13111. * Called by the particle System when the direction is computed for the created particle.
  13112. * @param worldMatrix is the world matrix of the particle system
  13113. * @param directionToUpdate is the direction vector to update with the result
  13114. * @param particle is the particle we are computed the direction for
  13115. * @param isLocal defines if the direction should be set in local space
  13116. */
  13117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13118. /**
  13119. * Called by the particle System when the position is computed for the created particle.
  13120. * @param worldMatrix is the world matrix of the particle system
  13121. * @param positionToUpdate is the position vector to update with the result
  13122. * @param particle is the particle we are computed the position for
  13123. * @param isLocal defines if the position should be set in local space
  13124. */
  13125. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13126. /**
  13127. * Clones the current emitter and returns a copy of it
  13128. * @returns the new emitter
  13129. */
  13130. clone(): BoxParticleEmitter;
  13131. /**
  13132. * Called by the GPUParticleSystem to setup the update shader
  13133. * @param effect defines the update shader
  13134. */
  13135. applyToShader(effect: Effect): void;
  13136. /**
  13137. * Returns a string to use to update the GPU particles update shader
  13138. * @returns a string containng the defines string
  13139. */
  13140. getEffectDefines(): string;
  13141. /**
  13142. * Returns the string "BoxParticleEmitter"
  13143. * @returns a string containing the class name
  13144. */
  13145. getClassName(): string;
  13146. /**
  13147. * Serializes the particle system to a JSON object.
  13148. * @returns the JSON object
  13149. */
  13150. serialize(): any;
  13151. /**
  13152. * Parse properties from a JSON object
  13153. * @param serializationObject defines the JSON object
  13154. */
  13155. parse(serializationObject: any): void;
  13156. }
  13157. }
  13158. declare module BABYLON {
  13159. /**
  13160. * Particle emitter emitting particles from the inside of a cone.
  13161. * It emits the particles alongside the cone volume from the base to the particle.
  13162. * The emission direction might be randomized.
  13163. */
  13164. export class ConeParticleEmitter implements IParticleEmitterType {
  13165. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13166. directionRandomizer: number;
  13167. private _radius;
  13168. private _angle;
  13169. private _height;
  13170. /**
  13171. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13172. */
  13173. radiusRange: number;
  13174. /**
  13175. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13176. */
  13177. heightRange: number;
  13178. /**
  13179. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13180. */
  13181. emitFromSpawnPointOnly: boolean;
  13182. /**
  13183. * Gets or sets the radius of the emission cone
  13184. */
  13185. get radius(): number;
  13186. set radius(value: number);
  13187. /**
  13188. * Gets or sets the angle of the emission cone
  13189. */
  13190. get angle(): number;
  13191. set angle(value: number);
  13192. private _buildHeight;
  13193. /**
  13194. * Creates a new instance ConeParticleEmitter
  13195. * @param radius the radius of the emission cone (1 by default)
  13196. * @param angle the cone base angle (PI by default)
  13197. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13198. */
  13199. constructor(radius?: number, angle?: number,
  13200. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13201. directionRandomizer?: number);
  13202. /**
  13203. * Called by the particle System when the direction is computed for the created particle.
  13204. * @param worldMatrix is the world matrix of the particle system
  13205. * @param directionToUpdate is the direction vector to update with the result
  13206. * @param particle is the particle we are computed the direction for
  13207. * @param isLocal defines if the direction should be set in local space
  13208. */
  13209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13210. /**
  13211. * Called by the particle System when the position is computed for the created particle.
  13212. * @param worldMatrix is the world matrix of the particle system
  13213. * @param positionToUpdate is the position vector to update with the result
  13214. * @param particle is the particle we are computed the position for
  13215. * @param isLocal defines if the position should be set in local space
  13216. */
  13217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13218. /**
  13219. * Clones the current emitter and returns a copy of it
  13220. * @returns the new emitter
  13221. */
  13222. clone(): ConeParticleEmitter;
  13223. /**
  13224. * Called by the GPUParticleSystem to setup the update shader
  13225. * @param effect defines the update shader
  13226. */
  13227. applyToShader(effect: Effect): void;
  13228. /**
  13229. * Returns a string to use to update the GPU particles update shader
  13230. * @returns a string containng the defines string
  13231. */
  13232. getEffectDefines(): string;
  13233. /**
  13234. * Returns the string "ConeParticleEmitter"
  13235. * @returns a string containing the class name
  13236. */
  13237. getClassName(): string;
  13238. /**
  13239. * Serializes the particle system to a JSON object.
  13240. * @returns the JSON object
  13241. */
  13242. serialize(): any;
  13243. /**
  13244. * Parse properties from a JSON object
  13245. * @param serializationObject defines the JSON object
  13246. */
  13247. parse(serializationObject: any): void;
  13248. }
  13249. }
  13250. declare module BABYLON {
  13251. /**
  13252. * Particle emitter emitting particles from the inside of a cylinder.
  13253. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13254. */
  13255. export class CylinderParticleEmitter implements IParticleEmitterType {
  13256. /**
  13257. * The radius of the emission cylinder.
  13258. */
  13259. radius: number;
  13260. /**
  13261. * The height of the emission cylinder.
  13262. */
  13263. height: number;
  13264. /**
  13265. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13266. */
  13267. radiusRange: number;
  13268. /**
  13269. * How much to randomize the particle direction [0-1].
  13270. */
  13271. directionRandomizer: number;
  13272. /**
  13273. * Creates a new instance CylinderParticleEmitter
  13274. * @param radius the radius of the emission cylinder (1 by default)
  13275. * @param height the height of the emission cylinder (1 by default)
  13276. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13277. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13278. */
  13279. constructor(
  13280. /**
  13281. * The radius of the emission cylinder.
  13282. */
  13283. radius?: number,
  13284. /**
  13285. * The height of the emission cylinder.
  13286. */
  13287. height?: number,
  13288. /**
  13289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13290. */
  13291. radiusRange?: number,
  13292. /**
  13293. * How much to randomize the particle direction [0-1].
  13294. */
  13295. directionRandomizer?: number);
  13296. /**
  13297. * Called by the particle System when the direction is computed for the created particle.
  13298. * @param worldMatrix is the world matrix of the particle system
  13299. * @param directionToUpdate is the direction vector to update with the result
  13300. * @param particle is the particle we are computed the direction for
  13301. * @param isLocal defines if the direction should be set in local space
  13302. */
  13303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13304. /**
  13305. * Called by the particle System when the position is computed for the created particle.
  13306. * @param worldMatrix is the world matrix of the particle system
  13307. * @param positionToUpdate is the position vector to update with the result
  13308. * @param particle is the particle we are computed the position for
  13309. * @param isLocal defines if the position should be set in local space
  13310. */
  13311. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13312. /**
  13313. * Clones the current emitter and returns a copy of it
  13314. * @returns the new emitter
  13315. */
  13316. clone(): CylinderParticleEmitter;
  13317. /**
  13318. * Called by the GPUParticleSystem to setup the update shader
  13319. * @param effect defines the update shader
  13320. */
  13321. applyToShader(effect: Effect): void;
  13322. /**
  13323. * Returns a string to use to update the GPU particles update shader
  13324. * @returns a string containng the defines string
  13325. */
  13326. getEffectDefines(): string;
  13327. /**
  13328. * Returns the string "CylinderParticleEmitter"
  13329. * @returns a string containing the class name
  13330. */
  13331. getClassName(): string;
  13332. /**
  13333. * Serializes the particle system to a JSON object.
  13334. * @returns the JSON object
  13335. */
  13336. serialize(): any;
  13337. /**
  13338. * Parse properties from a JSON object
  13339. * @param serializationObject defines the JSON object
  13340. */
  13341. parse(serializationObject: any): void;
  13342. }
  13343. /**
  13344. * Particle emitter emitting particles from the inside of a cylinder.
  13345. * It emits the particles randomly between two vectors.
  13346. */
  13347. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13348. /**
  13349. * The min limit of the emission direction.
  13350. */
  13351. direction1: Vector3;
  13352. /**
  13353. * The max limit of the emission direction.
  13354. */
  13355. direction2: Vector3;
  13356. /**
  13357. * Creates a new instance CylinderDirectedParticleEmitter
  13358. * @param radius the radius of the emission cylinder (1 by default)
  13359. * @param height the height of the emission cylinder (1 by default)
  13360. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13361. * @param direction1 the min limit of the emission direction (up vector by default)
  13362. * @param direction2 the max limit of the emission direction (up vector by default)
  13363. */
  13364. constructor(radius?: number, height?: number, radiusRange?: number,
  13365. /**
  13366. * The min limit of the emission direction.
  13367. */
  13368. direction1?: Vector3,
  13369. /**
  13370. * The max limit of the emission direction.
  13371. */
  13372. direction2?: Vector3);
  13373. /**
  13374. * Called by the particle System when the direction is computed for the created particle.
  13375. * @param worldMatrix is the world matrix of the particle system
  13376. * @param directionToUpdate is the direction vector to update with the result
  13377. * @param particle is the particle we are computed the direction for
  13378. */
  13379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13380. /**
  13381. * Clones the current emitter and returns a copy of it
  13382. * @returns the new emitter
  13383. */
  13384. clone(): CylinderDirectedParticleEmitter;
  13385. /**
  13386. * Called by the GPUParticleSystem to setup the update shader
  13387. * @param effect defines the update shader
  13388. */
  13389. applyToShader(effect: Effect): void;
  13390. /**
  13391. * Returns a string to use to update the GPU particles update shader
  13392. * @returns a string containng the defines string
  13393. */
  13394. getEffectDefines(): string;
  13395. /**
  13396. * Returns the string "CylinderDirectedParticleEmitter"
  13397. * @returns a string containing the class name
  13398. */
  13399. getClassName(): string;
  13400. /**
  13401. * Serializes the particle system to a JSON object.
  13402. * @returns the JSON object
  13403. */
  13404. serialize(): any;
  13405. /**
  13406. * Parse properties from a JSON object
  13407. * @param serializationObject defines the JSON object
  13408. */
  13409. parse(serializationObject: any): void;
  13410. }
  13411. }
  13412. declare module BABYLON {
  13413. /**
  13414. * Particle emitter emitting particles from the inside of a hemisphere.
  13415. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13416. */
  13417. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13418. /**
  13419. * The radius of the emission hemisphere.
  13420. */
  13421. radius: number;
  13422. /**
  13423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13424. */
  13425. radiusRange: number;
  13426. /**
  13427. * How much to randomize the particle direction [0-1].
  13428. */
  13429. directionRandomizer: number;
  13430. /**
  13431. * Creates a new instance HemisphericParticleEmitter
  13432. * @param radius the radius of the emission hemisphere (1 by default)
  13433. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13434. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13435. */
  13436. constructor(
  13437. /**
  13438. * The radius of the emission hemisphere.
  13439. */
  13440. radius?: number,
  13441. /**
  13442. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13443. */
  13444. radiusRange?: number,
  13445. /**
  13446. * How much to randomize the particle direction [0-1].
  13447. */
  13448. directionRandomizer?: number);
  13449. /**
  13450. * Called by the particle System when the direction is computed for the created particle.
  13451. * @param worldMatrix is the world matrix of the particle system
  13452. * @param directionToUpdate is the direction vector to update with the result
  13453. * @param particle is the particle we are computed the direction for
  13454. * @param isLocal defines if the direction should be set in local space
  13455. */
  13456. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13457. /**
  13458. * Called by the particle System when the position is computed for the created particle.
  13459. * @param worldMatrix is the world matrix of the particle system
  13460. * @param positionToUpdate is the position vector to update with the result
  13461. * @param particle is the particle we are computed the position for
  13462. * @param isLocal defines if the position should be set in local space
  13463. */
  13464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13465. /**
  13466. * Clones the current emitter and returns a copy of it
  13467. * @returns the new emitter
  13468. */
  13469. clone(): HemisphericParticleEmitter;
  13470. /**
  13471. * Called by the GPUParticleSystem to setup the update shader
  13472. * @param effect defines the update shader
  13473. */
  13474. applyToShader(effect: Effect): void;
  13475. /**
  13476. * Returns a string to use to update the GPU particles update shader
  13477. * @returns a string containng the defines string
  13478. */
  13479. getEffectDefines(): string;
  13480. /**
  13481. * Returns the string "HemisphericParticleEmitter"
  13482. * @returns a string containing the class name
  13483. */
  13484. getClassName(): string;
  13485. /**
  13486. * Serializes the particle system to a JSON object.
  13487. * @returns the JSON object
  13488. */
  13489. serialize(): any;
  13490. /**
  13491. * Parse properties from a JSON object
  13492. * @param serializationObject defines the JSON object
  13493. */
  13494. parse(serializationObject: any): void;
  13495. }
  13496. }
  13497. declare module BABYLON {
  13498. /**
  13499. * Particle emitter emitting particles from a point.
  13500. * It emits the particles randomly between 2 given directions.
  13501. */
  13502. export class PointParticleEmitter implements IParticleEmitterType {
  13503. /**
  13504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13505. */
  13506. direction1: Vector3;
  13507. /**
  13508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13509. */
  13510. direction2: Vector3;
  13511. /**
  13512. * Creates a new instance PointParticleEmitter
  13513. */
  13514. constructor();
  13515. /**
  13516. * Called by the particle System when the direction is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param directionToUpdate is the direction vector to update with the result
  13519. * @param particle is the particle we are computed the direction for
  13520. * @param isLocal defines if the direction should be set in local space
  13521. */
  13522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Called by the particle System when the position is computed for the created particle.
  13525. * @param worldMatrix is the world matrix of the particle system
  13526. * @param positionToUpdate is the position vector to update with the result
  13527. * @param particle is the particle we are computed the position for
  13528. * @param isLocal defines if the position should be set in local space
  13529. */
  13530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13531. /**
  13532. * Clones the current emitter and returns a copy of it
  13533. * @returns the new emitter
  13534. */
  13535. clone(): PointParticleEmitter;
  13536. /**
  13537. * Called by the GPUParticleSystem to setup the update shader
  13538. * @param effect defines the update shader
  13539. */
  13540. applyToShader(effect: Effect): void;
  13541. /**
  13542. * Returns a string to use to update the GPU particles update shader
  13543. * @returns a string containng the defines string
  13544. */
  13545. getEffectDefines(): string;
  13546. /**
  13547. * Returns the string "PointParticleEmitter"
  13548. * @returns a string containing the class name
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Serializes the particle system to a JSON object.
  13553. * @returns the JSON object
  13554. */
  13555. serialize(): any;
  13556. /**
  13557. * Parse properties from a JSON object
  13558. * @param serializationObject defines the JSON object
  13559. */
  13560. parse(serializationObject: any): void;
  13561. }
  13562. }
  13563. declare module BABYLON {
  13564. /**
  13565. * Particle emitter emitting particles from the inside of a sphere.
  13566. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13567. */
  13568. export class SphereParticleEmitter implements IParticleEmitterType {
  13569. /**
  13570. * The radius of the emission sphere.
  13571. */
  13572. radius: number;
  13573. /**
  13574. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13575. */
  13576. radiusRange: number;
  13577. /**
  13578. * How much to randomize the particle direction [0-1].
  13579. */
  13580. directionRandomizer: number;
  13581. /**
  13582. * Creates a new instance SphereParticleEmitter
  13583. * @param radius the radius of the emission sphere (1 by default)
  13584. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13586. */
  13587. constructor(
  13588. /**
  13589. * The radius of the emission sphere.
  13590. */
  13591. radius?: number,
  13592. /**
  13593. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13594. */
  13595. radiusRange?: number,
  13596. /**
  13597. * How much to randomize the particle direction [0-1].
  13598. */
  13599. directionRandomizer?: number);
  13600. /**
  13601. * Called by the particle System when the direction is computed for the created particle.
  13602. * @param worldMatrix is the world matrix of the particle system
  13603. * @param directionToUpdate is the direction vector to update with the result
  13604. * @param particle is the particle we are computed the direction for
  13605. * @param isLocal defines if the direction should be set in local space
  13606. */
  13607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13608. /**
  13609. * Called by the particle System when the position is computed for the created particle.
  13610. * @param worldMatrix is the world matrix of the particle system
  13611. * @param positionToUpdate is the position vector to update with the result
  13612. * @param particle is the particle we are computed the position for
  13613. * @param isLocal defines if the position should be set in local space
  13614. */
  13615. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13616. /**
  13617. * Clones the current emitter and returns a copy of it
  13618. * @returns the new emitter
  13619. */
  13620. clone(): SphereParticleEmitter;
  13621. /**
  13622. * Called by the GPUParticleSystem to setup the update shader
  13623. * @param effect defines the update shader
  13624. */
  13625. applyToShader(effect: Effect): void;
  13626. /**
  13627. * Returns a string to use to update the GPU particles update shader
  13628. * @returns a string containng the defines string
  13629. */
  13630. getEffectDefines(): string;
  13631. /**
  13632. * Returns the string "SphereParticleEmitter"
  13633. * @returns a string containing the class name
  13634. */
  13635. getClassName(): string;
  13636. /**
  13637. * Serializes the particle system to a JSON object.
  13638. * @returns the JSON object
  13639. */
  13640. serialize(): any;
  13641. /**
  13642. * Parse properties from a JSON object
  13643. * @param serializationObject defines the JSON object
  13644. */
  13645. parse(serializationObject: any): void;
  13646. }
  13647. /**
  13648. * Particle emitter emitting particles from the inside of a sphere.
  13649. * It emits the particles randomly between two vectors.
  13650. */
  13651. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13652. /**
  13653. * The min limit of the emission direction.
  13654. */
  13655. direction1: Vector3;
  13656. /**
  13657. * The max limit of the emission direction.
  13658. */
  13659. direction2: Vector3;
  13660. /**
  13661. * Creates a new instance SphereDirectedParticleEmitter
  13662. * @param radius the radius of the emission sphere (1 by default)
  13663. * @param direction1 the min limit of the emission direction (up vector by default)
  13664. * @param direction2 the max limit of the emission direction (up vector by default)
  13665. */
  13666. constructor(radius?: number,
  13667. /**
  13668. * The min limit of the emission direction.
  13669. */
  13670. direction1?: Vector3,
  13671. /**
  13672. * The max limit of the emission direction.
  13673. */
  13674. direction2?: Vector3);
  13675. /**
  13676. * Called by the particle System when the direction is computed for the created particle.
  13677. * @param worldMatrix is the world matrix of the particle system
  13678. * @param directionToUpdate is the direction vector to update with the result
  13679. * @param particle is the particle we are computed the direction for
  13680. */
  13681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13682. /**
  13683. * Clones the current emitter and returns a copy of it
  13684. * @returns the new emitter
  13685. */
  13686. clone(): SphereDirectedParticleEmitter;
  13687. /**
  13688. * Called by the GPUParticleSystem to setup the update shader
  13689. * @param effect defines the update shader
  13690. */
  13691. applyToShader(effect: Effect): void;
  13692. /**
  13693. * Returns a string to use to update the GPU particles update shader
  13694. * @returns a string containng the defines string
  13695. */
  13696. getEffectDefines(): string;
  13697. /**
  13698. * Returns the string "SphereDirectedParticleEmitter"
  13699. * @returns a string containing the class name
  13700. */
  13701. getClassName(): string;
  13702. /**
  13703. * Serializes the particle system to a JSON object.
  13704. * @returns the JSON object
  13705. */
  13706. serialize(): any;
  13707. /**
  13708. * Parse properties from a JSON object
  13709. * @param serializationObject defines the JSON object
  13710. */
  13711. parse(serializationObject: any): void;
  13712. }
  13713. }
  13714. declare module BABYLON {
  13715. /**
  13716. * Particle emitter emitting particles from a custom list of positions.
  13717. */
  13718. export class CustomParticleEmitter implements IParticleEmitterType {
  13719. /**
  13720. * Gets or sets the position generator that will create the inital position of each particle.
  13721. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13722. */
  13723. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13724. /**
  13725. * Gets or sets the destination generator that will create the final destination of each particle.
  13726. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13727. */
  13728. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13729. /**
  13730. * Creates a new instance CustomParticleEmitter
  13731. */
  13732. constructor();
  13733. /**
  13734. * Called by the particle System when the direction is computed for the created particle.
  13735. * @param worldMatrix is the world matrix of the particle system
  13736. * @param directionToUpdate is the direction vector to update with the result
  13737. * @param particle is the particle we are computed the direction for
  13738. * @param isLocal defines if the direction should be set in local space
  13739. */
  13740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13741. /**
  13742. * Called by the particle System when the position is computed for the created particle.
  13743. * @param worldMatrix is the world matrix of the particle system
  13744. * @param positionToUpdate is the position vector to update with the result
  13745. * @param particle is the particle we are computed the position for
  13746. * @param isLocal defines if the position should be set in local space
  13747. */
  13748. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13749. /**
  13750. * Clones the current emitter and returns a copy of it
  13751. * @returns the new emitter
  13752. */
  13753. clone(): CustomParticleEmitter;
  13754. /**
  13755. * Called by the GPUParticleSystem to setup the update shader
  13756. * @param effect defines the update shader
  13757. */
  13758. applyToShader(effect: Effect): void;
  13759. /**
  13760. * Returns a string to use to update the GPU particles update shader
  13761. * @returns a string containng the defines string
  13762. */
  13763. getEffectDefines(): string;
  13764. /**
  13765. * Returns the string "PointParticleEmitter"
  13766. * @returns a string containing the class name
  13767. */
  13768. getClassName(): string;
  13769. /**
  13770. * Serializes the particle system to a JSON object.
  13771. * @returns the JSON object
  13772. */
  13773. serialize(): any;
  13774. /**
  13775. * Parse properties from a JSON object
  13776. * @param serializationObject defines the JSON object
  13777. */
  13778. parse(serializationObject: any): void;
  13779. }
  13780. }
  13781. declare module BABYLON {
  13782. /**
  13783. * Particle emitter emitting particles from the inside of a box.
  13784. * It emits the particles randomly between 2 given directions.
  13785. */
  13786. export class MeshParticleEmitter implements IParticleEmitterType {
  13787. private _indices;
  13788. private _positions;
  13789. private _normals;
  13790. private _storedNormal;
  13791. private _mesh;
  13792. /**
  13793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13794. */
  13795. direction1: Vector3;
  13796. /**
  13797. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13798. */
  13799. direction2: Vector3;
  13800. /**
  13801. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13802. */
  13803. useMeshNormalsForDirection: boolean;
  13804. /** Defines the mesh to use as source */
  13805. get mesh(): Nullable<AbstractMesh>;
  13806. set mesh(value: Nullable<AbstractMesh>);
  13807. /**
  13808. * Creates a new instance MeshParticleEmitter
  13809. * @param mesh defines the mesh to use as source
  13810. */
  13811. constructor(mesh?: Nullable<AbstractMesh>);
  13812. /**
  13813. * Called by the particle System when the direction is computed for the created particle.
  13814. * @param worldMatrix is the world matrix of the particle system
  13815. * @param directionToUpdate is the direction vector to update with the result
  13816. * @param particle is the particle we are computed the direction for
  13817. * @param isLocal defines if the direction should be set in local space
  13818. */
  13819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13820. /**
  13821. * Called by the particle System when the position is computed for the created particle.
  13822. * @param worldMatrix is the world matrix of the particle system
  13823. * @param positionToUpdate is the position vector to update with the result
  13824. * @param particle is the particle we are computed the position for
  13825. * @param isLocal defines if the position should be set in local space
  13826. */
  13827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13828. /**
  13829. * Clones the current emitter and returns a copy of it
  13830. * @returns the new emitter
  13831. */
  13832. clone(): MeshParticleEmitter;
  13833. /**
  13834. * Called by the GPUParticleSystem to setup the update shader
  13835. * @param effect defines the update shader
  13836. */
  13837. applyToShader(effect: Effect): void;
  13838. /**
  13839. * Returns a string to use to update the GPU particles update shader
  13840. * @returns a string containng the defines string
  13841. */
  13842. getEffectDefines(): string;
  13843. /**
  13844. * Returns the string "BoxParticleEmitter"
  13845. * @returns a string containing the class name
  13846. */
  13847. getClassName(): string;
  13848. /**
  13849. * Serializes the particle system to a JSON object.
  13850. * @returns the JSON object
  13851. */
  13852. serialize(): any;
  13853. /**
  13854. * Parse properties from a JSON object
  13855. * @param serializationObject defines the JSON object
  13856. * @param scene defines the hosting scene
  13857. */
  13858. parse(serializationObject: any, scene: Scene): void;
  13859. }
  13860. }
  13861. declare module BABYLON {
  13862. /**
  13863. * Interface representing a particle system in Babylon.js.
  13864. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13865. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13866. */
  13867. export interface IParticleSystem {
  13868. /**
  13869. * List of animations used by the particle system.
  13870. */
  13871. animations: Animation[];
  13872. /**
  13873. * The id of the Particle system.
  13874. */
  13875. id: string;
  13876. /**
  13877. * The name of the Particle system.
  13878. */
  13879. name: string;
  13880. /**
  13881. * The emitter represents the Mesh or position we are attaching the particle system to.
  13882. */
  13883. emitter: Nullable<AbstractMesh | Vector3>;
  13884. /**
  13885. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13886. */
  13887. isBillboardBased: boolean;
  13888. /**
  13889. * The rendering group used by the Particle system to chose when to render.
  13890. */
  13891. renderingGroupId: number;
  13892. /**
  13893. * The layer mask we are rendering the particles through.
  13894. */
  13895. layerMask: number;
  13896. /**
  13897. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13898. */
  13899. updateSpeed: number;
  13900. /**
  13901. * The amount of time the particle system is running (depends of the overall update speed).
  13902. */
  13903. targetStopDuration: number;
  13904. /**
  13905. * The texture used to render each particle. (this can be a spritesheet)
  13906. */
  13907. particleTexture: Nullable<Texture>;
  13908. /**
  13909. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13910. */
  13911. blendMode: number;
  13912. /**
  13913. * Minimum life time of emitting particles.
  13914. */
  13915. minLifeTime: number;
  13916. /**
  13917. * Maximum life time of emitting particles.
  13918. */
  13919. maxLifeTime: number;
  13920. /**
  13921. * Minimum Size of emitting particles.
  13922. */
  13923. minSize: number;
  13924. /**
  13925. * Maximum Size of emitting particles.
  13926. */
  13927. maxSize: number;
  13928. /**
  13929. * Minimum scale of emitting particles on X axis.
  13930. */
  13931. minScaleX: number;
  13932. /**
  13933. * Maximum scale of emitting particles on X axis.
  13934. */
  13935. maxScaleX: number;
  13936. /**
  13937. * Minimum scale of emitting particles on Y axis.
  13938. */
  13939. minScaleY: number;
  13940. /**
  13941. * Maximum scale of emitting particles on Y axis.
  13942. */
  13943. maxScaleY: number;
  13944. /**
  13945. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13946. */
  13947. color1: Color4;
  13948. /**
  13949. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13950. */
  13951. color2: Color4;
  13952. /**
  13953. * Color the particle will have at the end of its lifetime.
  13954. */
  13955. colorDead: Color4;
  13956. /**
  13957. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13958. */
  13959. emitRate: number;
  13960. /**
  13961. * You can use gravity if you want to give an orientation to your particles.
  13962. */
  13963. gravity: Vector3;
  13964. /**
  13965. * Minimum power of emitting particles.
  13966. */
  13967. minEmitPower: number;
  13968. /**
  13969. * Maximum power of emitting particles.
  13970. */
  13971. maxEmitPower: number;
  13972. /**
  13973. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13974. */
  13975. minAngularSpeed: number;
  13976. /**
  13977. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13978. */
  13979. maxAngularSpeed: number;
  13980. /**
  13981. * Gets or sets the minimal initial rotation in radians.
  13982. */
  13983. minInitialRotation: number;
  13984. /**
  13985. * Gets or sets the maximal initial rotation in radians.
  13986. */
  13987. maxInitialRotation: number;
  13988. /**
  13989. * The particle emitter type defines the emitter used by the particle system.
  13990. * It can be for example box, sphere, or cone...
  13991. */
  13992. particleEmitterType: Nullable<IParticleEmitterType>;
  13993. /**
  13994. * Defines the delay in milliseconds before starting the system (0 by default)
  13995. */
  13996. startDelay: number;
  13997. /**
  13998. * 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
  13999. */
  14000. preWarmCycles: number;
  14001. /**
  14002. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14003. */
  14004. preWarmStepOffset: number;
  14005. /**
  14006. * 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)
  14007. */
  14008. spriteCellChangeSpeed: number;
  14009. /**
  14010. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14011. */
  14012. startSpriteCellID: number;
  14013. /**
  14014. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14015. */
  14016. endSpriteCellID: number;
  14017. /**
  14018. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14019. */
  14020. spriteCellWidth: number;
  14021. /**
  14022. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14023. */
  14024. spriteCellHeight: number;
  14025. /**
  14026. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14027. */
  14028. spriteRandomStartCell: boolean;
  14029. /**
  14030. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14031. */
  14032. isAnimationSheetEnabled: boolean;
  14033. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14034. translationPivot: Vector2;
  14035. /**
  14036. * Gets or sets a texture used to add random noise to particle positions
  14037. */
  14038. noiseTexture: Nullable<BaseTexture>;
  14039. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14040. noiseStrength: Vector3;
  14041. /**
  14042. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14043. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14044. */
  14045. billboardMode: number;
  14046. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14047. limitVelocityDamping: number;
  14048. /**
  14049. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14050. */
  14051. beginAnimationOnStart: boolean;
  14052. /**
  14053. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14054. */
  14055. beginAnimationFrom: number;
  14056. /**
  14057. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14058. */
  14059. beginAnimationTo: number;
  14060. /**
  14061. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14062. */
  14063. beginAnimationLoop: boolean;
  14064. /**
  14065. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14066. */
  14067. disposeOnStop: boolean;
  14068. /**
  14069. * Specifies if the particles are updated in emitter local space or world space
  14070. */
  14071. isLocal: boolean;
  14072. /** Snippet ID if the particle system was created from the snippet server */
  14073. snippetId: string;
  14074. /**
  14075. * Gets the maximum number of particles active at the same time.
  14076. * @returns The max number of active particles.
  14077. */
  14078. getCapacity(): number;
  14079. /**
  14080. * Gets the number of particles active at the same time.
  14081. * @returns The number of active particles.
  14082. */
  14083. getActiveCount(): number;
  14084. /**
  14085. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14086. * @returns True if it has been started, otherwise false.
  14087. */
  14088. isStarted(): boolean;
  14089. /**
  14090. * Animates the particle system for this frame.
  14091. */
  14092. animate(): void;
  14093. /**
  14094. * Renders the particle system in its current state.
  14095. * @returns the current number of particles
  14096. */
  14097. render(): number;
  14098. /**
  14099. * Dispose the particle system and frees its associated resources.
  14100. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14101. */
  14102. dispose(disposeTexture?: boolean): void;
  14103. /**
  14104. * An event triggered when the system is disposed
  14105. */
  14106. onDisposeObservable: Observable<IParticleSystem>;
  14107. /**
  14108. * Clones the particle system.
  14109. * @param name The name of the cloned object
  14110. * @param newEmitter The new emitter to use
  14111. * @returns the cloned particle system
  14112. */
  14113. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14114. /**
  14115. * Serializes the particle system to a JSON object
  14116. * @param serializeTexture defines if the texture must be serialized as well
  14117. * @returns the JSON object
  14118. */
  14119. serialize(serializeTexture: boolean): any;
  14120. /**
  14121. * Rebuild the particle system
  14122. */
  14123. rebuild(): void;
  14124. /** Force the system to rebuild all gradients that need to be resync */
  14125. forceRefreshGradients(): void;
  14126. /**
  14127. * Starts the particle system and begins to emit
  14128. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14129. */
  14130. start(delay?: number): void;
  14131. /**
  14132. * Stops the particle system.
  14133. */
  14134. stop(): void;
  14135. /**
  14136. * Remove all active particles
  14137. */
  14138. reset(): void;
  14139. /**
  14140. * Gets a boolean indicating that the system is stopping
  14141. * @returns true if the system is currently stopping
  14142. */
  14143. isStopping(): boolean;
  14144. /**
  14145. * Is this system ready to be used/rendered
  14146. * @return true if the system is ready
  14147. */
  14148. isReady(): boolean;
  14149. /**
  14150. * Returns the string "ParticleSystem"
  14151. * @returns a string containing the class name
  14152. */
  14153. getClassName(): string;
  14154. /**
  14155. * Gets the custom effect used to render the particles
  14156. * @param blendMode Blend mode for which the effect should be retrieved
  14157. * @returns The effect
  14158. */
  14159. getCustomEffect(blendMode: number): Nullable<Effect>;
  14160. /**
  14161. * Sets the custom effect used to render the particles
  14162. * @param effect The effect to set
  14163. * @param blendMode Blend mode for which the effect should be set
  14164. */
  14165. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14166. /**
  14167. * Fill the defines array according to the current settings of the particle system
  14168. * @param defines Array to be updated
  14169. * @param blendMode blend mode to take into account when updating the array
  14170. */
  14171. fillDefines(defines: Array<string>, blendMode: number): void;
  14172. /**
  14173. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14174. * @param uniforms Uniforms array to fill
  14175. * @param attributes Attributes array to fill
  14176. * @param samplers Samplers array to fill
  14177. */
  14178. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14179. /**
  14180. * Observable that will be called just before the particles are drawn
  14181. */
  14182. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14183. /**
  14184. * Gets the name of the particle vertex shader
  14185. */
  14186. vertexShaderName: string;
  14187. /**
  14188. * Adds a new color gradient
  14189. * @param gradient defines the gradient to use (between 0 and 1)
  14190. * @param color1 defines the color to affect to the specified gradient
  14191. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14192. * @returns the current particle system
  14193. */
  14194. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14195. /**
  14196. * Remove a specific color gradient
  14197. * @param gradient defines the gradient to remove
  14198. * @returns the current particle system
  14199. */
  14200. removeColorGradient(gradient: number): IParticleSystem;
  14201. /**
  14202. * Adds a new size gradient
  14203. * @param gradient defines the gradient to use (between 0 and 1)
  14204. * @param factor defines the size factor to affect to the specified gradient
  14205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14206. * @returns the current particle system
  14207. */
  14208. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14209. /**
  14210. * Remove a specific size gradient
  14211. * @param gradient defines the gradient to remove
  14212. * @returns the current particle system
  14213. */
  14214. removeSizeGradient(gradient: number): IParticleSystem;
  14215. /**
  14216. * Gets the current list of color gradients.
  14217. * You must use addColorGradient and removeColorGradient to udpate this list
  14218. * @returns the list of color gradients
  14219. */
  14220. getColorGradients(): Nullable<Array<ColorGradient>>;
  14221. /**
  14222. * Gets the current list of size gradients.
  14223. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14224. * @returns the list of size gradients
  14225. */
  14226. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14227. /**
  14228. * Gets the current list of angular speed gradients.
  14229. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14230. * @returns the list of angular speed gradients
  14231. */
  14232. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14233. /**
  14234. * Adds a new angular speed gradient
  14235. * @param gradient defines the gradient to use (between 0 and 1)
  14236. * @param factor defines the angular speed to affect to the specified gradient
  14237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14238. * @returns the current particle system
  14239. */
  14240. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14241. /**
  14242. * Remove a specific angular speed gradient
  14243. * @param gradient defines the gradient to remove
  14244. * @returns the current particle system
  14245. */
  14246. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14247. /**
  14248. * Gets the current list of velocity gradients.
  14249. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14250. * @returns the list of velocity gradients
  14251. */
  14252. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Adds a new velocity gradient
  14255. * @param gradient defines the gradient to use (between 0 and 1)
  14256. * @param factor defines the velocity to affect to the specified gradient
  14257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14258. * @returns the current particle system
  14259. */
  14260. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14261. /**
  14262. * Remove a specific velocity gradient
  14263. * @param gradient defines the gradient to remove
  14264. * @returns the current particle system
  14265. */
  14266. removeVelocityGradient(gradient: number): IParticleSystem;
  14267. /**
  14268. * Gets the current list of limit velocity gradients.
  14269. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14270. * @returns the list of limit velocity gradients
  14271. */
  14272. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14273. /**
  14274. * Adds a new limit velocity gradient
  14275. * @param gradient defines the gradient to use (between 0 and 1)
  14276. * @param factor defines the limit velocity to affect to the specified gradient
  14277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14278. * @returns the current particle system
  14279. */
  14280. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14281. /**
  14282. * Remove a specific limit velocity gradient
  14283. * @param gradient defines the gradient to remove
  14284. * @returns the current particle system
  14285. */
  14286. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14287. /**
  14288. * Adds a new drag gradient
  14289. * @param gradient defines the gradient to use (between 0 and 1)
  14290. * @param factor defines the drag to affect to the specified gradient
  14291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14292. * @returns the current particle system
  14293. */
  14294. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14295. /**
  14296. * Remove a specific drag gradient
  14297. * @param gradient defines the gradient to remove
  14298. * @returns the current particle system
  14299. */
  14300. removeDragGradient(gradient: number): IParticleSystem;
  14301. /**
  14302. * Gets the current list of drag gradients.
  14303. * You must use addDragGradient and removeDragGradient to udpate this list
  14304. * @returns the list of drag gradients
  14305. */
  14306. getDragGradients(): Nullable<Array<FactorGradient>>;
  14307. /**
  14308. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14309. * @param gradient defines the gradient to use (between 0 and 1)
  14310. * @param factor defines the emit rate to affect to the specified gradient
  14311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14312. * @returns the current particle system
  14313. */
  14314. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14315. /**
  14316. * Remove a specific emit rate gradient
  14317. * @param gradient defines the gradient to remove
  14318. * @returns the current particle system
  14319. */
  14320. removeEmitRateGradient(gradient: number): IParticleSystem;
  14321. /**
  14322. * Gets the current list of emit rate gradients.
  14323. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14324. * @returns the list of emit rate gradients
  14325. */
  14326. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14327. /**
  14328. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14329. * @param gradient defines the gradient to use (between 0 and 1)
  14330. * @param factor defines the start size to affect to the specified gradient
  14331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14332. * @returns the current particle system
  14333. */
  14334. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14335. /**
  14336. * Remove a specific start size gradient
  14337. * @param gradient defines the gradient to remove
  14338. * @returns the current particle system
  14339. */
  14340. removeStartSizeGradient(gradient: number): IParticleSystem;
  14341. /**
  14342. * Gets the current list of start size gradients.
  14343. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14344. * @returns the list of start size gradients
  14345. */
  14346. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Adds a new life time gradient
  14349. * @param gradient defines the gradient to use (between 0 and 1)
  14350. * @param factor defines the life time factor to affect to the specified gradient
  14351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14352. * @returns the current particle system
  14353. */
  14354. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14355. /**
  14356. * Remove a specific life time gradient
  14357. * @param gradient defines the gradient to remove
  14358. * @returns the current particle system
  14359. */
  14360. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14361. /**
  14362. * Gets the current list of life time gradients.
  14363. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14364. * @returns the list of life time gradients
  14365. */
  14366. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Gets the current list of color gradients.
  14369. * You must use addColorGradient and removeColorGradient to udpate this list
  14370. * @returns the list of color gradients
  14371. */
  14372. getColorGradients(): Nullable<Array<ColorGradient>>;
  14373. /**
  14374. * Adds a new ramp gradient used to remap particle colors
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param color defines the color to affect to the specified gradient
  14377. * @returns the current particle system
  14378. */
  14379. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14380. /**
  14381. * Gets the current list of ramp gradients.
  14382. * You must use addRampGradient and removeRampGradient to udpate this list
  14383. * @returns the list of ramp gradients
  14384. */
  14385. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14386. /** Gets or sets a boolean indicating that ramp gradients must be used
  14387. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14388. */
  14389. useRampGradients: boolean;
  14390. /**
  14391. * Adds a new color remap gradient
  14392. * @param gradient defines the gradient to use (between 0 and 1)
  14393. * @param min defines the color remap minimal range
  14394. * @param max defines the color remap maximal range
  14395. * @returns the current particle system
  14396. */
  14397. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14398. /**
  14399. * Gets the current list of color remap gradients.
  14400. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14401. * @returns the list of color remap gradients
  14402. */
  14403. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Adds a new alpha remap gradient
  14406. * @param gradient defines the gradient to use (between 0 and 1)
  14407. * @param min defines the alpha remap minimal range
  14408. * @param max defines the alpha remap maximal range
  14409. * @returns the current particle system
  14410. */
  14411. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14412. /**
  14413. * Gets the current list of alpha remap gradients.
  14414. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14415. * @returns the list of alpha remap gradients
  14416. */
  14417. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14418. /**
  14419. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14420. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14421. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14422. * @returns the emitter
  14423. */
  14424. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14425. /**
  14426. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14427. * @param radius The radius of the hemisphere to emit from
  14428. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14429. * @returns the emitter
  14430. */
  14431. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14432. /**
  14433. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14434. * @param radius The radius of the sphere to emit from
  14435. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14436. * @returns the emitter
  14437. */
  14438. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14439. /**
  14440. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14441. * @param radius The radius of the sphere to emit from
  14442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14444. * @returns the emitter
  14445. */
  14446. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14447. /**
  14448. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14449. * @param radius The radius of the emission cylinder
  14450. * @param height The height of the emission cylinder
  14451. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14452. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14453. * @returns the emitter
  14454. */
  14455. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14456. /**
  14457. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14458. * @param radius The radius of the cylinder to emit from
  14459. * @param height The height of the emission cylinder
  14460. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14463. * @returns the emitter
  14464. */
  14465. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14466. /**
  14467. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14468. * @param radius The radius of the cone to emit from
  14469. * @param angle The base angle of the cone
  14470. * @returns the emitter
  14471. */
  14472. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14473. /**
  14474. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14475. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14476. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14477. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14478. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14479. * @returns the emitter
  14480. */
  14481. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14482. /**
  14483. * Get hosting scene
  14484. * @returns the scene
  14485. */
  14486. getScene(): Scene;
  14487. }
  14488. }
  14489. declare module BABYLON {
  14490. /**
  14491. * 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.
  14492. * @see https://doc.babylonjs.com/how_to/transformnode
  14493. */
  14494. export class TransformNode extends Node {
  14495. /**
  14496. * Object will not rotate to face the camera
  14497. */
  14498. static BILLBOARDMODE_NONE: number;
  14499. /**
  14500. * Object will rotate to face the camera but only on the x axis
  14501. */
  14502. static BILLBOARDMODE_X: number;
  14503. /**
  14504. * Object will rotate to face the camera but only on the y axis
  14505. */
  14506. static BILLBOARDMODE_Y: number;
  14507. /**
  14508. * Object will rotate to face the camera but only on the z axis
  14509. */
  14510. static BILLBOARDMODE_Z: number;
  14511. /**
  14512. * Object will rotate to face the camera
  14513. */
  14514. static BILLBOARDMODE_ALL: number;
  14515. /**
  14516. * Object will rotate to face the camera's position instead of orientation
  14517. */
  14518. static BILLBOARDMODE_USE_POSITION: number;
  14519. private static _TmpRotation;
  14520. private static _TmpScaling;
  14521. private static _TmpTranslation;
  14522. private _forward;
  14523. private _forwardInverted;
  14524. private _up;
  14525. private _right;
  14526. private _rightInverted;
  14527. private _position;
  14528. private _rotation;
  14529. private _rotationQuaternion;
  14530. protected _scaling: Vector3;
  14531. protected _isDirty: boolean;
  14532. private _transformToBoneReferal;
  14533. private _isAbsoluteSynced;
  14534. private _billboardMode;
  14535. /**
  14536. * Gets or sets the billboard mode. Default is 0.
  14537. *
  14538. * | Value | Type | Description |
  14539. * | --- | --- | --- |
  14540. * | 0 | BILLBOARDMODE_NONE | |
  14541. * | 1 | BILLBOARDMODE_X | |
  14542. * | 2 | BILLBOARDMODE_Y | |
  14543. * | 4 | BILLBOARDMODE_Z | |
  14544. * | 7 | BILLBOARDMODE_ALL | |
  14545. *
  14546. */
  14547. get billboardMode(): number;
  14548. set billboardMode(value: number);
  14549. private _preserveParentRotationForBillboard;
  14550. /**
  14551. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14552. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14553. */
  14554. get preserveParentRotationForBillboard(): boolean;
  14555. set preserveParentRotationForBillboard(value: boolean);
  14556. /**
  14557. * 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
  14558. */
  14559. scalingDeterminant: number;
  14560. private _infiniteDistance;
  14561. /**
  14562. * Gets or sets the distance of the object to max, often used by skybox
  14563. */
  14564. get infiniteDistance(): boolean;
  14565. set infiniteDistance(value: boolean);
  14566. /**
  14567. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14568. * By default the system will update normals to compensate
  14569. */
  14570. ignoreNonUniformScaling: boolean;
  14571. /**
  14572. * 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
  14573. */
  14574. reIntegrateRotationIntoRotationQuaternion: boolean;
  14575. /** @hidden */
  14576. _poseMatrix: Nullable<Matrix>;
  14577. /** @hidden */
  14578. _localMatrix: Matrix;
  14579. private _usePivotMatrix;
  14580. private _absolutePosition;
  14581. private _absoluteScaling;
  14582. private _absoluteRotationQuaternion;
  14583. private _pivotMatrix;
  14584. private _pivotMatrixInverse;
  14585. protected _postMultiplyPivotMatrix: boolean;
  14586. protected _isWorldMatrixFrozen: boolean;
  14587. /** @hidden */
  14588. _indexInSceneTransformNodesArray: number;
  14589. /**
  14590. * An event triggered after the world matrix is updated
  14591. */
  14592. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14593. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14594. /**
  14595. * Gets a string identifying the name of the class
  14596. * @returns "TransformNode" string
  14597. */
  14598. getClassName(): string;
  14599. /**
  14600. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14601. */
  14602. get position(): Vector3;
  14603. set position(newPosition: Vector3);
  14604. /**
  14605. * 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)).
  14606. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14607. */
  14608. get rotation(): Vector3;
  14609. set rotation(newRotation: Vector3);
  14610. /**
  14611. * 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)).
  14612. */
  14613. get scaling(): Vector3;
  14614. set scaling(newScaling: Vector3);
  14615. /**
  14616. * 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).
  14617. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14618. */
  14619. get rotationQuaternion(): Nullable<Quaternion>;
  14620. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14621. /**
  14622. * The forward direction of that transform in world space.
  14623. */
  14624. get forward(): Vector3;
  14625. /**
  14626. * The up direction of that transform in world space.
  14627. */
  14628. get up(): Vector3;
  14629. /**
  14630. * The right direction of that transform in world space.
  14631. */
  14632. get right(): Vector3;
  14633. /**
  14634. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14635. * @param matrix the matrix to copy the pose from
  14636. * @returns this TransformNode.
  14637. */
  14638. updatePoseMatrix(matrix: Matrix): TransformNode;
  14639. /**
  14640. * Returns the mesh Pose matrix.
  14641. * @returns the pose matrix
  14642. */
  14643. getPoseMatrix(): Matrix;
  14644. /** @hidden */
  14645. _isSynchronized(): boolean;
  14646. /** @hidden */
  14647. _initCache(): void;
  14648. /**
  14649. * Flag the transform node as dirty (Forcing it to update everything)
  14650. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14651. * @returns this transform node
  14652. */
  14653. markAsDirty(property: string): TransformNode;
  14654. /**
  14655. * Returns the current mesh absolute position.
  14656. * Returns a Vector3.
  14657. */
  14658. get absolutePosition(): Vector3;
  14659. /**
  14660. * Returns the current mesh absolute scaling.
  14661. * Returns a Vector3.
  14662. */
  14663. get absoluteScaling(): Vector3;
  14664. /**
  14665. * Returns the current mesh absolute rotation.
  14666. * Returns a Quaternion.
  14667. */
  14668. get absoluteRotationQuaternion(): Quaternion;
  14669. /**
  14670. * Sets a new matrix to apply before all other transformation
  14671. * @param matrix defines the transform matrix
  14672. * @returns the current TransformNode
  14673. */
  14674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14675. /**
  14676. * Sets a new pivot matrix to the current node
  14677. * @param matrix defines the new pivot matrix to use
  14678. * @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
  14679. * @returns the current TransformNode
  14680. */
  14681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14682. /**
  14683. * Returns the mesh pivot matrix.
  14684. * Default : Identity.
  14685. * @returns the matrix
  14686. */
  14687. getPivotMatrix(): Matrix;
  14688. /**
  14689. * Instantiate (when possible) or clone that node with its hierarchy
  14690. * @param newParent defines the new parent to use for the instance (or clone)
  14691. * @param options defines options to configure how copy is done
  14692. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14693. * @returns an instance (or a clone) of the current node with its hiearchy
  14694. */
  14695. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14696. doNotInstantiate: boolean;
  14697. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14698. /**
  14699. * Prevents the World matrix to be computed any longer
  14700. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14701. * @returns the TransformNode.
  14702. */
  14703. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14704. /**
  14705. * Allows back the World matrix computation.
  14706. * @returns the TransformNode.
  14707. */
  14708. unfreezeWorldMatrix(): this;
  14709. /**
  14710. * True if the World matrix has been frozen.
  14711. */
  14712. get isWorldMatrixFrozen(): boolean;
  14713. /**
  14714. * Retuns the mesh absolute position in the World.
  14715. * @returns a Vector3.
  14716. */
  14717. getAbsolutePosition(): Vector3;
  14718. /**
  14719. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14720. * @param absolutePosition the absolute position to set
  14721. * @returns the TransformNode.
  14722. */
  14723. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14724. /**
  14725. * Sets the mesh position in its local space.
  14726. * @param vector3 the position to set in localspace
  14727. * @returns the TransformNode.
  14728. */
  14729. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14730. /**
  14731. * Returns the mesh position in the local space from the current World matrix values.
  14732. * @returns a new Vector3.
  14733. */
  14734. getPositionExpressedInLocalSpace(): Vector3;
  14735. /**
  14736. * Translates the mesh along the passed Vector3 in its local space.
  14737. * @param vector3 the distance to translate in localspace
  14738. * @returns the TransformNode.
  14739. */
  14740. locallyTranslate(vector3: Vector3): TransformNode;
  14741. private static _lookAtVectorCache;
  14742. /**
  14743. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14744. * @param targetPoint the position (must be in same space as current mesh) to look at
  14745. * @param yawCor optional yaw (y-axis) correction in radians
  14746. * @param pitchCor optional pitch (x-axis) correction in radians
  14747. * @param rollCor optional roll (z-axis) correction in radians
  14748. * @param space the choosen space of the target
  14749. * @returns the TransformNode.
  14750. */
  14751. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14752. /**
  14753. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14754. * This Vector3 is expressed in the World space.
  14755. * @param localAxis axis to rotate
  14756. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14757. */
  14758. getDirection(localAxis: Vector3): Vector3;
  14759. /**
  14760. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14761. * localAxis is expressed in the mesh local space.
  14762. * result is computed in the Wordl space from the mesh World matrix.
  14763. * @param localAxis axis to rotate
  14764. * @param result the resulting transformnode
  14765. * @returns this TransformNode.
  14766. */
  14767. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14768. /**
  14769. * Sets this transform node rotation to the given local axis.
  14770. * @param localAxis the axis in local space
  14771. * @param yawCor optional yaw (y-axis) correction in radians
  14772. * @param pitchCor optional pitch (x-axis) correction in radians
  14773. * @param rollCor optional roll (z-axis) correction in radians
  14774. * @returns this TransformNode
  14775. */
  14776. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14777. /**
  14778. * Sets a new pivot point to the current node
  14779. * @param point defines the new pivot point to use
  14780. * @param space defines if the point is in world or local space (local by default)
  14781. * @returns the current TransformNode
  14782. */
  14783. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14784. /**
  14785. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14786. * @returns the pivot point
  14787. */
  14788. getPivotPoint(): Vector3;
  14789. /**
  14790. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14791. * @param result the vector3 to store the result
  14792. * @returns this TransformNode.
  14793. */
  14794. getPivotPointToRef(result: Vector3): TransformNode;
  14795. /**
  14796. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14797. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14798. */
  14799. getAbsolutePivotPoint(): Vector3;
  14800. /**
  14801. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14802. * @param result vector3 to store the result
  14803. * @returns this TransformNode.
  14804. */
  14805. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14806. /**
  14807. * Defines the passed node as the parent of the current node.
  14808. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14809. * @see https://doc.babylonjs.com/how_to/parenting
  14810. * @param node the node ot set as the parent
  14811. * @returns this TransformNode.
  14812. */
  14813. setParent(node: Nullable<Node>): TransformNode;
  14814. private _nonUniformScaling;
  14815. /**
  14816. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14817. */
  14818. get nonUniformScaling(): boolean;
  14819. /** @hidden */
  14820. _updateNonUniformScalingState(value: boolean): boolean;
  14821. /**
  14822. * Attach the current TransformNode to another TransformNode associated with a bone
  14823. * @param bone Bone affecting the TransformNode
  14824. * @param affectedTransformNode TransformNode associated with the bone
  14825. * @returns this object
  14826. */
  14827. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14828. /**
  14829. * Detach the transform node if its associated with a bone
  14830. * @returns this object
  14831. */
  14832. detachFromBone(): TransformNode;
  14833. private static _rotationAxisCache;
  14834. /**
  14835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14836. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14837. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14838. * The passed axis is also normalized.
  14839. * @param axis the axis to rotate around
  14840. * @param amount the amount to rotate in radians
  14841. * @param space Space to rotate in (Default: local)
  14842. * @returns the TransformNode.
  14843. */
  14844. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14845. /**
  14846. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14847. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14848. * The passed axis is also normalized. .
  14849. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14850. * @param point the point to rotate around
  14851. * @param axis the axis to rotate around
  14852. * @param amount the amount to rotate in radians
  14853. * @returns the TransformNode
  14854. */
  14855. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14856. /**
  14857. * Translates the mesh along the axis vector for the passed distance in the given space.
  14858. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14859. * @param axis the axis to translate in
  14860. * @param distance the distance to translate
  14861. * @param space Space to rotate in (Default: local)
  14862. * @returns the TransformNode.
  14863. */
  14864. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14865. /**
  14866. * Adds a rotation step to the mesh current rotation.
  14867. * x, y, z are Euler angles expressed in radians.
  14868. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14869. * This means this rotation is made in the mesh local space only.
  14870. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14871. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14872. * ```javascript
  14873. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14874. * ```
  14875. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14876. * 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.
  14877. * @param x Rotation to add
  14878. * @param y Rotation to add
  14879. * @param z Rotation to add
  14880. * @returns the TransformNode.
  14881. */
  14882. addRotation(x: number, y: number, z: number): TransformNode;
  14883. /**
  14884. * @hidden
  14885. */
  14886. protected _getEffectiveParent(): Nullable<Node>;
  14887. /**
  14888. * Computes the world matrix of the node
  14889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14890. * @returns the world matrix
  14891. */
  14892. computeWorldMatrix(force?: boolean): Matrix;
  14893. /**
  14894. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14895. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14896. */
  14897. resetLocalMatrix(independentOfChildren?: boolean): void;
  14898. protected _afterComputeWorldMatrix(): void;
  14899. /**
  14900. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14901. * @param func callback function to add
  14902. *
  14903. * @returns the TransformNode.
  14904. */
  14905. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14906. /**
  14907. * Removes a registered callback function.
  14908. * @param func callback function to remove
  14909. * @returns the TransformNode.
  14910. */
  14911. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14912. /**
  14913. * Gets the position of the current mesh in camera space
  14914. * @param camera defines the camera to use
  14915. * @returns a position
  14916. */
  14917. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14918. /**
  14919. * Returns the distance from the mesh to the active camera
  14920. * @param camera defines the camera to use
  14921. * @returns the distance
  14922. */
  14923. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14924. /**
  14925. * Clone the current transform node
  14926. * @param name Name of the new clone
  14927. * @param newParent New parent for the clone
  14928. * @param doNotCloneChildren Do not clone children hierarchy
  14929. * @returns the new transform node
  14930. */
  14931. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14932. /**
  14933. * Serializes the objects information.
  14934. * @param currentSerializationObject defines the object to serialize in
  14935. * @returns the serialized object
  14936. */
  14937. serialize(currentSerializationObject?: any): any;
  14938. /**
  14939. * Returns a new TransformNode object parsed from the source provided.
  14940. * @param parsedTransformNode is the source.
  14941. * @param scene the scne the object belongs to
  14942. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14943. * @returns a new TransformNode object parsed from the source provided.
  14944. */
  14945. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14946. /**
  14947. * Get all child-transformNodes of this node
  14948. * @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
  14949. * @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
  14950. * @returns an array of TransformNode
  14951. */
  14952. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14953. /**
  14954. * Releases resources associated with this transform node.
  14955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14957. */
  14958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14959. /**
  14960. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14961. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14962. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14963. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14964. * @returns the current mesh
  14965. */
  14966. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14967. private _syncAbsoluteScalingAndRotation;
  14968. }
  14969. }
  14970. declare module BABYLON {
  14971. /**
  14972. * Class used to override all child animations of a given target
  14973. */
  14974. export class AnimationPropertiesOverride {
  14975. /**
  14976. * Gets or sets a value indicating if animation blending must be used
  14977. */
  14978. enableBlending: boolean;
  14979. /**
  14980. * Gets or sets the blending speed to use when enableBlending is true
  14981. */
  14982. blendingSpeed: number;
  14983. /**
  14984. * Gets or sets the default loop mode to use
  14985. */
  14986. loopMode: number;
  14987. }
  14988. }
  14989. declare module BABYLON {
  14990. /**
  14991. * Class used to store bone information
  14992. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14993. */
  14994. export class Bone extends Node {
  14995. /**
  14996. * defines the bone name
  14997. */
  14998. name: string;
  14999. private static _tmpVecs;
  15000. private static _tmpQuat;
  15001. private static _tmpMats;
  15002. /**
  15003. * Gets the list of child bones
  15004. */
  15005. children: Bone[];
  15006. /** Gets the animations associated with this bone */
  15007. animations: Animation[];
  15008. /**
  15009. * Gets or sets bone length
  15010. */
  15011. length: number;
  15012. /**
  15013. * @hidden Internal only
  15014. * Set this value to map this bone to a different index in the transform matrices
  15015. * Set this value to -1 to exclude the bone from the transform matrices
  15016. */
  15017. _index: Nullable<number>;
  15018. private _skeleton;
  15019. private _localMatrix;
  15020. private _restPose;
  15021. private _baseMatrix;
  15022. private _absoluteTransform;
  15023. private _invertedAbsoluteTransform;
  15024. private _parent;
  15025. private _scalingDeterminant;
  15026. private _worldTransform;
  15027. private _localScaling;
  15028. private _localRotation;
  15029. private _localPosition;
  15030. private _needToDecompose;
  15031. private _needToCompose;
  15032. /** @hidden */
  15033. _linkedTransformNode: Nullable<TransformNode>;
  15034. /** @hidden */
  15035. _waitingTransformNodeId: Nullable<string>;
  15036. /** @hidden */
  15037. get _matrix(): Matrix;
  15038. /** @hidden */
  15039. set _matrix(value: Matrix);
  15040. /**
  15041. * Create a new bone
  15042. * @param name defines the bone name
  15043. * @param skeleton defines the parent skeleton
  15044. * @param parentBone defines the parent (can be null if the bone is the root)
  15045. * @param localMatrix defines the local matrix
  15046. * @param restPose defines the rest pose matrix
  15047. * @param baseMatrix defines the base matrix
  15048. * @param index defines index of the bone in the hiearchy
  15049. */
  15050. constructor(
  15051. /**
  15052. * defines the bone name
  15053. */
  15054. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15055. /**
  15056. * Gets the current object class name.
  15057. * @return the class name
  15058. */
  15059. getClassName(): string;
  15060. /**
  15061. * Gets the parent skeleton
  15062. * @returns a skeleton
  15063. */
  15064. getSkeleton(): Skeleton;
  15065. /**
  15066. * Gets parent bone
  15067. * @returns a bone or null if the bone is the root of the bone hierarchy
  15068. */
  15069. getParent(): Nullable<Bone>;
  15070. /**
  15071. * Returns an array containing the root bones
  15072. * @returns an array containing the root bones
  15073. */
  15074. getChildren(): Array<Bone>;
  15075. /**
  15076. * Gets the node index in matrix array generated for rendering
  15077. * @returns the node index
  15078. */
  15079. getIndex(): number;
  15080. /**
  15081. * Sets the parent bone
  15082. * @param parent defines the parent (can be null if the bone is the root)
  15083. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15084. */
  15085. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15086. /**
  15087. * Gets the local matrix
  15088. * @returns a matrix
  15089. */
  15090. getLocalMatrix(): Matrix;
  15091. /**
  15092. * Gets the base matrix (initial matrix which remains unchanged)
  15093. * @returns a matrix
  15094. */
  15095. getBaseMatrix(): Matrix;
  15096. /**
  15097. * Gets the rest pose matrix
  15098. * @returns a matrix
  15099. */
  15100. getRestPose(): Matrix;
  15101. /**
  15102. * Sets the rest pose matrix
  15103. * @param matrix the local-space rest pose to set for this bone
  15104. */
  15105. setRestPose(matrix: Matrix): void;
  15106. /**
  15107. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15108. */
  15109. getWorldMatrix(): Matrix;
  15110. /**
  15111. * Sets the local matrix to rest pose matrix
  15112. */
  15113. returnToRest(): void;
  15114. /**
  15115. * Gets the inverse of the absolute transform matrix.
  15116. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15117. * @returns a matrix
  15118. */
  15119. getInvertedAbsoluteTransform(): Matrix;
  15120. /**
  15121. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15122. * @returns a matrix
  15123. */
  15124. getAbsoluteTransform(): Matrix;
  15125. /**
  15126. * Links with the given transform node.
  15127. * The local matrix of this bone is copied from the transform node every frame.
  15128. * @param transformNode defines the transform node to link to
  15129. */
  15130. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15131. /**
  15132. * Gets the node used to drive the bone's transformation
  15133. * @returns a transform node or null
  15134. */
  15135. getTransformNode(): Nullable<TransformNode>;
  15136. /** Gets or sets current position (in local space) */
  15137. get position(): Vector3;
  15138. set position(newPosition: Vector3);
  15139. /** Gets or sets current rotation (in local space) */
  15140. get rotation(): Vector3;
  15141. set rotation(newRotation: Vector3);
  15142. /** Gets or sets current rotation quaternion (in local space) */
  15143. get rotationQuaternion(): Quaternion;
  15144. set rotationQuaternion(newRotation: Quaternion);
  15145. /** Gets or sets current scaling (in local space) */
  15146. get scaling(): Vector3;
  15147. set scaling(newScaling: Vector3);
  15148. /**
  15149. * Gets the animation properties override
  15150. */
  15151. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15152. private _decompose;
  15153. private _compose;
  15154. /**
  15155. * Update the base and local matrices
  15156. * @param matrix defines the new base or local matrix
  15157. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15158. * @param updateLocalMatrix defines if the local matrix should be updated
  15159. */
  15160. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15161. /** @hidden */
  15162. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15163. /**
  15164. * Flag the bone as dirty (Forcing it to update everything)
  15165. */
  15166. markAsDirty(): void;
  15167. /** @hidden */
  15168. _markAsDirtyAndCompose(): void;
  15169. private _markAsDirtyAndDecompose;
  15170. /**
  15171. * Translate the bone in local or world space
  15172. * @param vec The amount to translate the bone
  15173. * @param space The space that the translation is in
  15174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15175. */
  15176. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15177. /**
  15178. * Set the postion of the bone in local or world space
  15179. * @param position The position to set the bone
  15180. * @param space The space that the position is in
  15181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15182. */
  15183. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15184. /**
  15185. * Set the absolute position of the bone (world space)
  15186. * @param position The position to set the bone
  15187. * @param mesh The mesh that this bone is attached to
  15188. */
  15189. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15190. /**
  15191. * Scale the bone on the x, y and z axes (in local space)
  15192. * @param x The amount to scale the bone on the x axis
  15193. * @param y The amount to scale the bone on the y axis
  15194. * @param z The amount to scale the bone on the z axis
  15195. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15196. */
  15197. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15198. /**
  15199. * Set the bone scaling in local space
  15200. * @param scale defines the scaling vector
  15201. */
  15202. setScale(scale: Vector3): void;
  15203. /**
  15204. * Gets the current scaling in local space
  15205. * @returns the current scaling vector
  15206. */
  15207. getScale(): Vector3;
  15208. /**
  15209. * Gets the current scaling in local space and stores it in a target vector
  15210. * @param result defines the target vector
  15211. */
  15212. getScaleToRef(result: Vector3): void;
  15213. /**
  15214. * Set the yaw, pitch, and roll of the bone in local or world space
  15215. * @param yaw The rotation of the bone on the y axis
  15216. * @param pitch The rotation of the bone on the x axis
  15217. * @param roll The rotation of the bone on the z axis
  15218. * @param space The space that the axes of rotation are in
  15219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15220. */
  15221. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15222. /**
  15223. * Add a rotation to the bone on an axis in local or world space
  15224. * @param axis The axis to rotate the bone on
  15225. * @param amount The amount to rotate the bone
  15226. * @param space The space that the axis is in
  15227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15228. */
  15229. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15230. /**
  15231. * Set the rotation of the bone to a particular axis angle in local or world space
  15232. * @param axis The axis to rotate the bone on
  15233. * @param angle The angle that the bone should be rotated to
  15234. * @param space The space that the axis is in
  15235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15236. */
  15237. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15238. /**
  15239. * Set the euler rotation of the bone in local of world space
  15240. * @param rotation The euler rotation that the bone should be set to
  15241. * @param space The space that the rotation is in
  15242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15243. */
  15244. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15245. /**
  15246. * Set the quaternion rotation of the bone in local of world space
  15247. * @param quat The quaternion rotation that the bone should be set to
  15248. * @param space The space that the rotation is in
  15249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15250. */
  15251. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15252. /**
  15253. * Set the rotation matrix of the bone in local of world space
  15254. * @param rotMat The rotation matrix that the bone should be set to
  15255. * @param space The space that the rotation is in
  15256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15257. */
  15258. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15259. private _rotateWithMatrix;
  15260. private _getNegativeRotationToRef;
  15261. /**
  15262. * Get the position of the bone in local or world space
  15263. * @param space The space that the returned position is in
  15264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15265. * @returns The position of the bone
  15266. */
  15267. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15268. /**
  15269. * Copy the position of the bone to a vector3 in local or world space
  15270. * @param space The space that the returned position is in
  15271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15272. * @param result The vector3 to copy the position to
  15273. */
  15274. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15275. /**
  15276. * Get the absolute position of the bone (world space)
  15277. * @param mesh The mesh that this bone is attached to
  15278. * @returns The absolute position of the bone
  15279. */
  15280. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15281. /**
  15282. * Copy the absolute position of the bone (world space) to the result param
  15283. * @param mesh The mesh that this bone is attached to
  15284. * @param result The vector3 to copy the absolute position to
  15285. */
  15286. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15287. /**
  15288. * Compute the absolute transforms of this bone and its children
  15289. */
  15290. computeAbsoluteTransforms(): void;
  15291. /**
  15292. * Get the world direction from an axis that is in the local space of the bone
  15293. * @param localAxis The local direction that is used to compute the world direction
  15294. * @param mesh The mesh that this bone is attached to
  15295. * @returns The world direction
  15296. */
  15297. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15298. /**
  15299. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15300. * @param localAxis The local direction that is used to compute the world direction
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @param result The vector3 that the world direction will be copied to
  15303. */
  15304. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15305. /**
  15306. * Get the euler rotation of the bone in local or world space
  15307. * @param space The space that the rotation should be in
  15308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15309. * @returns The euler rotation
  15310. */
  15311. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15312. /**
  15313. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15314. * @param space The space that the rotation should be in
  15315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15316. * @param result The vector3 that the rotation should be copied to
  15317. */
  15318. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15319. /**
  15320. * Get the quaternion rotation of the bone in either local or world space
  15321. * @param space The space that the rotation should be in
  15322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15323. * @returns The quaternion rotation
  15324. */
  15325. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15326. /**
  15327. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15328. * @param space The space that the rotation should be in
  15329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15330. * @param result The quaternion that the rotation should be copied to
  15331. */
  15332. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15333. /**
  15334. * Get the rotation matrix of the bone in local or world space
  15335. * @param space The space that the rotation should be in
  15336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15337. * @returns The rotation matrix
  15338. */
  15339. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15340. /**
  15341. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15342. * @param space The space that the rotation should be in
  15343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15344. * @param result The quaternion that the rotation should be copied to
  15345. */
  15346. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15347. /**
  15348. * Get the world position of a point that is in the local space of the bone
  15349. * @param position The local position
  15350. * @param mesh The mesh that this bone is attached to
  15351. * @returns The world position
  15352. */
  15353. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15354. /**
  15355. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15356. * @param position The local position
  15357. * @param mesh The mesh that this bone is attached to
  15358. * @param result The vector3 that the world position should be copied to
  15359. */
  15360. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15361. /**
  15362. * Get the local position of a point that is in world space
  15363. * @param position The world position
  15364. * @param mesh The mesh that this bone is attached to
  15365. * @returns The local position
  15366. */
  15367. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15368. /**
  15369. * Get the local position of a point that is in world space and copy it to the result param
  15370. * @param position The world position
  15371. * @param mesh The mesh that this bone is attached to
  15372. * @param result The vector3 that the local position should be copied to
  15373. */
  15374. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15375. }
  15376. }
  15377. declare module BABYLON {
  15378. /**
  15379. * Defines a runtime animation
  15380. */
  15381. export class RuntimeAnimation {
  15382. private _events;
  15383. /**
  15384. * The current frame of the runtime animation
  15385. */
  15386. private _currentFrame;
  15387. /**
  15388. * The animation used by the runtime animation
  15389. */
  15390. private _animation;
  15391. /**
  15392. * The target of the runtime animation
  15393. */
  15394. private _target;
  15395. /**
  15396. * The initiating animatable
  15397. */
  15398. private _host;
  15399. /**
  15400. * The original value of the runtime animation
  15401. */
  15402. private _originalValue;
  15403. /**
  15404. * The original blend value of the runtime animation
  15405. */
  15406. private _originalBlendValue;
  15407. /**
  15408. * The offsets cache of the runtime animation
  15409. */
  15410. private _offsetsCache;
  15411. /**
  15412. * The high limits cache of the runtime animation
  15413. */
  15414. private _highLimitsCache;
  15415. /**
  15416. * Specifies if the runtime animation has been stopped
  15417. */
  15418. private _stopped;
  15419. /**
  15420. * The blending factor of the runtime animation
  15421. */
  15422. private _blendingFactor;
  15423. /**
  15424. * The BabylonJS scene
  15425. */
  15426. private _scene;
  15427. /**
  15428. * The current value of the runtime animation
  15429. */
  15430. private _currentValue;
  15431. /** @hidden */
  15432. _animationState: _IAnimationState;
  15433. /**
  15434. * The active target of the runtime animation
  15435. */
  15436. private _activeTargets;
  15437. private _currentActiveTarget;
  15438. private _directTarget;
  15439. /**
  15440. * The target path of the runtime animation
  15441. */
  15442. private _targetPath;
  15443. /**
  15444. * The weight of the runtime animation
  15445. */
  15446. private _weight;
  15447. /**
  15448. * The ratio offset of the runtime animation
  15449. */
  15450. private _ratioOffset;
  15451. /**
  15452. * The previous delay of the runtime animation
  15453. */
  15454. private _previousDelay;
  15455. /**
  15456. * The previous ratio of the runtime animation
  15457. */
  15458. private _previousRatio;
  15459. private _enableBlending;
  15460. private _keys;
  15461. private _minFrame;
  15462. private _maxFrame;
  15463. private _minValue;
  15464. private _maxValue;
  15465. private _targetIsArray;
  15466. /**
  15467. * Gets the current frame of the runtime animation
  15468. */
  15469. get currentFrame(): number;
  15470. /**
  15471. * Gets the weight of the runtime animation
  15472. */
  15473. get weight(): number;
  15474. /**
  15475. * Gets the current value of the runtime animation
  15476. */
  15477. get currentValue(): any;
  15478. /**
  15479. * Gets the target path of the runtime animation
  15480. */
  15481. get targetPath(): string;
  15482. /**
  15483. * Gets the actual target of the runtime animation
  15484. */
  15485. get target(): any;
  15486. /**
  15487. * Gets the additive state of the runtime animation
  15488. */
  15489. get isAdditive(): boolean;
  15490. /** @hidden */
  15491. _onLoop: () => void;
  15492. /**
  15493. * Create a new RuntimeAnimation object
  15494. * @param target defines the target of the animation
  15495. * @param animation defines the source animation object
  15496. * @param scene defines the hosting scene
  15497. * @param host defines the initiating Animatable
  15498. */
  15499. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15500. private _preparePath;
  15501. /**
  15502. * Gets the animation from the runtime animation
  15503. */
  15504. get animation(): Animation;
  15505. /**
  15506. * Resets the runtime animation to the beginning
  15507. * @param restoreOriginal defines whether to restore the target property to the original value
  15508. */
  15509. reset(restoreOriginal?: boolean): void;
  15510. /**
  15511. * Specifies if the runtime animation is stopped
  15512. * @returns Boolean specifying if the runtime animation is stopped
  15513. */
  15514. isStopped(): boolean;
  15515. /**
  15516. * Disposes of the runtime animation
  15517. */
  15518. dispose(): void;
  15519. /**
  15520. * Apply the interpolated value to the target
  15521. * @param currentValue defines the value computed by the animation
  15522. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15523. */
  15524. setValue(currentValue: any, weight: number): void;
  15525. private _getOriginalValues;
  15526. private _setValue;
  15527. /**
  15528. * Gets the loop pmode of the runtime animation
  15529. * @returns Loop Mode
  15530. */
  15531. private _getCorrectLoopMode;
  15532. /**
  15533. * Move the current animation to a given frame
  15534. * @param frame defines the frame to move to
  15535. */
  15536. goToFrame(frame: number): void;
  15537. /**
  15538. * @hidden Internal use only
  15539. */
  15540. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15541. /**
  15542. * Execute the current animation
  15543. * @param delay defines the delay to add to the current frame
  15544. * @param from defines the lower bound of the animation range
  15545. * @param to defines the upper bound of the animation range
  15546. * @param loop defines if the current animation must loop
  15547. * @param speedRatio defines the current speed ratio
  15548. * @param weight defines the weight of the animation (default is -1 so no weight)
  15549. * @param onLoop optional callback called when animation loops
  15550. * @returns a boolean indicating if the animation is running
  15551. */
  15552. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /**
  15557. * Class used to store an actual running animation
  15558. */
  15559. export class Animatable {
  15560. /** defines the target object */
  15561. target: any;
  15562. /** defines the starting frame number (default is 0) */
  15563. fromFrame: number;
  15564. /** defines the ending frame number (default is 100) */
  15565. toFrame: number;
  15566. /** defines if the animation must loop (default is false) */
  15567. loopAnimation: boolean;
  15568. /** defines a callback to call when animation ends if it is not looping */
  15569. onAnimationEnd?: (() => void) | null | undefined;
  15570. /** defines a callback to call when animation loops */
  15571. onAnimationLoop?: (() => void) | null | undefined;
  15572. /** defines whether the animation should be evaluated additively */
  15573. isAdditive: boolean;
  15574. private _localDelayOffset;
  15575. private _pausedDelay;
  15576. private _runtimeAnimations;
  15577. private _paused;
  15578. private _scene;
  15579. private _speedRatio;
  15580. private _weight;
  15581. private _syncRoot;
  15582. /**
  15583. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15584. * This will only apply for non looping animation (default is true)
  15585. */
  15586. disposeOnEnd: boolean;
  15587. /**
  15588. * Gets a boolean indicating if the animation has started
  15589. */
  15590. animationStarted: boolean;
  15591. /**
  15592. * Observer raised when the animation ends
  15593. */
  15594. onAnimationEndObservable: Observable<Animatable>;
  15595. /**
  15596. * Observer raised when the animation loops
  15597. */
  15598. onAnimationLoopObservable: Observable<Animatable>;
  15599. /**
  15600. * Gets the root Animatable used to synchronize and normalize animations
  15601. */
  15602. get syncRoot(): Nullable<Animatable>;
  15603. /**
  15604. * Gets the current frame of the first RuntimeAnimation
  15605. * Used to synchronize Animatables
  15606. */
  15607. get masterFrame(): number;
  15608. /**
  15609. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15610. */
  15611. get weight(): number;
  15612. set weight(value: number);
  15613. /**
  15614. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15615. */
  15616. get speedRatio(): number;
  15617. set speedRatio(value: number);
  15618. /**
  15619. * Creates a new Animatable
  15620. * @param scene defines the hosting scene
  15621. * @param target defines the target object
  15622. * @param fromFrame defines the starting frame number (default is 0)
  15623. * @param toFrame defines the ending frame number (default is 100)
  15624. * @param loopAnimation defines if the animation must loop (default is false)
  15625. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15626. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15627. * @param animations defines a group of animation to add to the new Animatable
  15628. * @param onAnimationLoop defines a callback to call when animation loops
  15629. * @param isAdditive defines whether the animation should be evaluated additively
  15630. */
  15631. constructor(scene: Scene,
  15632. /** defines the target object */
  15633. target: any,
  15634. /** defines the starting frame number (default is 0) */
  15635. fromFrame?: number,
  15636. /** defines the ending frame number (default is 100) */
  15637. toFrame?: number,
  15638. /** defines if the animation must loop (default is false) */
  15639. loopAnimation?: boolean, speedRatio?: number,
  15640. /** defines a callback to call when animation ends if it is not looping */
  15641. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15642. /** defines a callback to call when animation loops */
  15643. onAnimationLoop?: (() => void) | null | undefined,
  15644. /** defines whether the animation should be evaluated additively */
  15645. isAdditive?: boolean);
  15646. /**
  15647. * Synchronize and normalize current Animatable with a source Animatable
  15648. * This is useful when using animation weights and when animations are not of the same length
  15649. * @param root defines the root Animatable to synchronize with
  15650. * @returns the current Animatable
  15651. */
  15652. syncWith(root: Animatable): Animatable;
  15653. /**
  15654. * Gets the list of runtime animations
  15655. * @returns an array of RuntimeAnimation
  15656. */
  15657. getAnimations(): RuntimeAnimation[];
  15658. /**
  15659. * Adds more animations to the current animatable
  15660. * @param target defines the target of the animations
  15661. * @param animations defines the new animations to add
  15662. */
  15663. appendAnimations(target: any, animations: Animation[]): void;
  15664. /**
  15665. * Gets the source animation for a specific property
  15666. * @param property defines the propertyu to look for
  15667. * @returns null or the source animation for the given property
  15668. */
  15669. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15670. /**
  15671. * Gets the runtime animation for a specific property
  15672. * @param property defines the propertyu to look for
  15673. * @returns null or the runtime animation for the given property
  15674. */
  15675. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15676. /**
  15677. * Resets the animatable to its original state
  15678. */
  15679. reset(): void;
  15680. /**
  15681. * Allows the animatable to blend with current running animations
  15682. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15683. * @param blendingSpeed defines the blending speed to use
  15684. */
  15685. enableBlending(blendingSpeed: number): void;
  15686. /**
  15687. * Disable animation blending
  15688. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15689. */
  15690. disableBlending(): void;
  15691. /**
  15692. * Jump directly to a given frame
  15693. * @param frame defines the frame to jump to
  15694. */
  15695. goToFrame(frame: number): void;
  15696. /**
  15697. * Pause the animation
  15698. */
  15699. pause(): void;
  15700. /**
  15701. * Restart the animation
  15702. */
  15703. restart(): void;
  15704. private _raiseOnAnimationEnd;
  15705. /**
  15706. * Stop and delete the current animation
  15707. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15708. * @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)
  15709. */
  15710. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15711. /**
  15712. * Wait asynchronously for the animation to end
  15713. * @returns a promise which will be fullfilled when the animation ends
  15714. */
  15715. waitAsync(): Promise<Animatable>;
  15716. /** @hidden */
  15717. _animate(delay: number): boolean;
  15718. }
  15719. interface Scene {
  15720. /** @hidden */
  15721. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15722. /** @hidden */
  15723. _processLateAnimationBindingsForMatrices(holder: {
  15724. totalWeight: number;
  15725. totalAdditiveWeight: number;
  15726. animations: RuntimeAnimation[];
  15727. additiveAnimations: RuntimeAnimation[];
  15728. originalValue: Matrix;
  15729. }): any;
  15730. /** @hidden */
  15731. _processLateAnimationBindingsForQuaternions(holder: {
  15732. totalWeight: number;
  15733. totalAdditiveWeight: number;
  15734. animations: RuntimeAnimation[];
  15735. additiveAnimations: RuntimeAnimation[];
  15736. originalValue: Quaternion;
  15737. }, refQuaternion: Quaternion): Quaternion;
  15738. /** @hidden */
  15739. _processLateAnimationBindings(): void;
  15740. /**
  15741. * Will start the animation sequence of a given target
  15742. * @param target defines the target
  15743. * @param from defines from which frame should animation start
  15744. * @param to defines until which frame should animation run.
  15745. * @param weight defines the weight to apply to the animation (1.0 by default)
  15746. * @param loop defines if the animation loops
  15747. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15748. * @param onAnimationEnd defines the function to be executed when the animation ends
  15749. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15750. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15751. * @param onAnimationLoop defines the callback to call when an animation loops
  15752. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15753. * @returns the animatable object created for this animation
  15754. */
  15755. 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;
  15756. /**
  15757. * Will start the animation sequence of a given target
  15758. * @param target defines the target
  15759. * @param from defines from which frame should animation start
  15760. * @param to defines until which frame should animation run.
  15761. * @param loop defines if the animation loops
  15762. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15763. * @param onAnimationEnd defines the function to be executed when the animation ends
  15764. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15765. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15766. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15767. * @param onAnimationLoop defines the callback to call when an animation loops
  15768. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15769. * @returns the animatable object created for this animation
  15770. */
  15771. 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;
  15772. /**
  15773. * Will start the animation sequence of a given target and its hierarchy
  15774. * @param target defines the target
  15775. * @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.
  15776. * @param from defines from which frame should animation start
  15777. * @param to defines until which frame should animation run.
  15778. * @param loop defines if the animation loops
  15779. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15780. * @param onAnimationEnd defines the function to be executed when the animation ends
  15781. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15782. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15783. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15784. * @param onAnimationLoop defines the callback to call when an animation loops
  15785. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15786. * @returns the list of created animatables
  15787. */
  15788. 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[];
  15789. /**
  15790. * Begin a new animation on a given node
  15791. * @param target defines the target where the animation will take place
  15792. * @param animations defines the list of animations to start
  15793. * @param from defines the initial value
  15794. * @param to defines the final value
  15795. * @param loop defines if you want animation to loop (off by default)
  15796. * @param speedRatio defines the speed ratio to apply to all animations
  15797. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15798. * @param onAnimationLoop defines the callback to call when an animation loops
  15799. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15800. * @returns the list of created animatables
  15801. */
  15802. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15803. /**
  15804. * Begin a new animation on a given node and its hierarchy
  15805. * @param target defines the root node where the animation will take place
  15806. * @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.
  15807. * @param animations defines the list of animations to start
  15808. * @param from defines the initial value
  15809. * @param to defines the final value
  15810. * @param loop defines if you want animation to loop (off by default)
  15811. * @param speedRatio defines the speed ratio to apply to all animations
  15812. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15813. * @param onAnimationLoop defines the callback to call when an animation loops
  15814. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15815. * @returns the list of animatables created for all nodes
  15816. */
  15817. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15818. /**
  15819. * Gets the animatable associated with a specific target
  15820. * @param target defines the target of the animatable
  15821. * @returns the required animatable if found
  15822. */
  15823. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15824. /**
  15825. * Gets all animatables associated with a given target
  15826. * @param target defines the target to look animatables for
  15827. * @returns an array of Animatables
  15828. */
  15829. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15830. /**
  15831. * Stops and removes all animations that have been applied to the scene
  15832. */
  15833. stopAllAnimations(): void;
  15834. /**
  15835. * Gets the current delta time used by animation engine
  15836. */
  15837. deltaTime: number;
  15838. }
  15839. interface Bone {
  15840. /**
  15841. * Copy an animation range from another bone
  15842. * @param source defines the source bone
  15843. * @param rangeName defines the range name to copy
  15844. * @param frameOffset defines the frame offset
  15845. * @param rescaleAsRequired defines if rescaling must be applied if required
  15846. * @param skelDimensionsRatio defines the scaling ratio
  15847. * @returns true if operation was successful
  15848. */
  15849. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15850. }
  15851. }
  15852. declare module BABYLON {
  15853. /**
  15854. * Class used to handle skinning animations
  15855. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15856. */
  15857. export class Skeleton implements IAnimatable {
  15858. /** defines the skeleton name */
  15859. name: string;
  15860. /** defines the skeleton Id */
  15861. id: string;
  15862. /**
  15863. * Defines the list of child bones
  15864. */
  15865. bones: Bone[];
  15866. /**
  15867. * Defines an estimate of the dimension of the skeleton at rest
  15868. */
  15869. dimensionsAtRest: Vector3;
  15870. /**
  15871. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15872. */
  15873. needInitialSkinMatrix: boolean;
  15874. /**
  15875. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15876. */
  15877. overrideMesh: Nullable<AbstractMesh>;
  15878. /**
  15879. * Gets the list of animations attached to this skeleton
  15880. */
  15881. animations: Array<Animation>;
  15882. private _scene;
  15883. private _isDirty;
  15884. private _transformMatrices;
  15885. private _transformMatrixTexture;
  15886. private _meshesWithPoseMatrix;
  15887. private _animatables;
  15888. private _identity;
  15889. private _synchronizedWithMesh;
  15890. private _ranges;
  15891. private _lastAbsoluteTransformsUpdateId;
  15892. private _canUseTextureForBones;
  15893. private _uniqueId;
  15894. /** @hidden */
  15895. _numBonesWithLinkedTransformNode: number;
  15896. /** @hidden */
  15897. _hasWaitingData: Nullable<boolean>;
  15898. /**
  15899. * Specifies if the skeleton should be serialized
  15900. */
  15901. doNotSerialize: boolean;
  15902. private _useTextureToStoreBoneMatrices;
  15903. /**
  15904. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15905. * Please note that this option is not available if the hardware does not support it
  15906. */
  15907. get useTextureToStoreBoneMatrices(): boolean;
  15908. set useTextureToStoreBoneMatrices(value: boolean);
  15909. private _animationPropertiesOverride;
  15910. /**
  15911. * Gets or sets the animation properties override
  15912. */
  15913. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15914. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15915. /**
  15916. * List of inspectable custom properties (used by the Inspector)
  15917. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15918. */
  15919. inspectableCustomProperties: IInspectable[];
  15920. /**
  15921. * An observable triggered before computing the skeleton's matrices
  15922. */
  15923. onBeforeComputeObservable: Observable<Skeleton>;
  15924. /**
  15925. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15926. */
  15927. get isUsingTextureForMatrices(): boolean;
  15928. /**
  15929. * Gets the unique ID of this skeleton
  15930. */
  15931. get uniqueId(): number;
  15932. /**
  15933. * Creates a new skeleton
  15934. * @param name defines the skeleton name
  15935. * @param id defines the skeleton Id
  15936. * @param scene defines the hosting scene
  15937. */
  15938. constructor(
  15939. /** defines the skeleton name */
  15940. name: string,
  15941. /** defines the skeleton Id */
  15942. id: string, scene: Scene);
  15943. /**
  15944. * Gets the current object class name.
  15945. * @return the class name
  15946. */
  15947. getClassName(): string;
  15948. /**
  15949. * Returns an array containing the root bones
  15950. * @returns an array containing the root bones
  15951. */
  15952. getChildren(): Array<Bone>;
  15953. /**
  15954. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15955. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15956. * @returns a Float32Array containing matrices data
  15957. */
  15958. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15959. /**
  15960. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15961. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15962. * @returns a raw texture containing the data
  15963. */
  15964. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15965. /**
  15966. * Gets the current hosting scene
  15967. * @returns a scene object
  15968. */
  15969. getScene(): Scene;
  15970. /**
  15971. * Gets a string representing the current skeleton data
  15972. * @param fullDetails defines a boolean indicating if we want a verbose version
  15973. * @returns a string representing the current skeleton data
  15974. */
  15975. toString(fullDetails?: boolean): string;
  15976. /**
  15977. * Get bone's index searching by name
  15978. * @param name defines bone's name to search for
  15979. * @return the indice of the bone. Returns -1 if not found
  15980. */
  15981. getBoneIndexByName(name: string): number;
  15982. /**
  15983. * Creater a new animation range
  15984. * @param name defines the name of the range
  15985. * @param from defines the start key
  15986. * @param to defines the end key
  15987. */
  15988. createAnimationRange(name: string, from: number, to: number): void;
  15989. /**
  15990. * Delete a specific animation range
  15991. * @param name defines the name of the range
  15992. * @param deleteFrames defines if frames must be removed as well
  15993. */
  15994. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15995. /**
  15996. * Gets a specific animation range
  15997. * @param name defines the name of the range to look for
  15998. * @returns the requested animation range or null if not found
  15999. */
  16000. getAnimationRange(name: string): Nullable<AnimationRange>;
  16001. /**
  16002. * Gets the list of all animation ranges defined on this skeleton
  16003. * @returns an array
  16004. */
  16005. getAnimationRanges(): Nullable<AnimationRange>[];
  16006. /**
  16007. * Copy animation range from a source skeleton.
  16008. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16009. * @param source defines the source skeleton
  16010. * @param name defines the name of the range to copy
  16011. * @param rescaleAsRequired defines if rescaling must be applied if required
  16012. * @returns true if operation was successful
  16013. */
  16014. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16015. /**
  16016. * Forces the skeleton to go to rest pose
  16017. */
  16018. returnToRest(): void;
  16019. private _getHighestAnimationFrame;
  16020. /**
  16021. * Begin a specific animation range
  16022. * @param name defines the name of the range to start
  16023. * @param loop defines if looping must be turned on (false by default)
  16024. * @param speedRatio defines the speed ratio to apply (1 by default)
  16025. * @param onAnimationEnd defines a callback which will be called when animation will end
  16026. * @returns a new animatable
  16027. */
  16028. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16029. /**
  16030. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16031. * @param skeleton defines the Skeleton containing the animation range to convert
  16032. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16033. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16034. * @returns the original skeleton
  16035. */
  16036. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16037. /** @hidden */
  16038. _markAsDirty(): void;
  16039. /** @hidden */
  16040. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16041. /** @hidden */
  16042. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16043. private _computeTransformMatrices;
  16044. /**
  16045. * Build all resources required to render a skeleton
  16046. */
  16047. prepare(): void;
  16048. /**
  16049. * Gets the list of animatables currently running for this skeleton
  16050. * @returns an array of animatables
  16051. */
  16052. getAnimatables(): IAnimatable[];
  16053. /**
  16054. * Clone the current skeleton
  16055. * @param name defines the name of the new skeleton
  16056. * @param id defines the id of the new skeleton
  16057. * @returns the new skeleton
  16058. */
  16059. clone(name: string, id?: string): Skeleton;
  16060. /**
  16061. * Enable animation blending for this skeleton
  16062. * @param blendingSpeed defines the blending speed to apply
  16063. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16064. */
  16065. enableBlending(blendingSpeed?: number): void;
  16066. /**
  16067. * Releases all resources associated with the current skeleton
  16068. */
  16069. dispose(): void;
  16070. /**
  16071. * Serialize the skeleton in a JSON object
  16072. * @returns a JSON object
  16073. */
  16074. serialize(): any;
  16075. /**
  16076. * Creates a new skeleton from serialized data
  16077. * @param parsedSkeleton defines the serialized data
  16078. * @param scene defines the hosting scene
  16079. * @returns a new skeleton
  16080. */
  16081. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16082. /**
  16083. * Compute all node absolute transforms
  16084. * @param forceUpdate defines if computation must be done even if cache is up to date
  16085. */
  16086. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16087. /**
  16088. * Gets the root pose matrix
  16089. * @returns a matrix
  16090. */
  16091. getPoseMatrix(): Nullable<Matrix>;
  16092. /**
  16093. * Sorts bones per internal index
  16094. */
  16095. sortBones(): void;
  16096. private _sortBones;
  16097. }
  16098. }
  16099. declare module BABYLON {
  16100. /**
  16101. * Creates an instance based on a source mesh.
  16102. */
  16103. export class InstancedMesh extends AbstractMesh {
  16104. private _sourceMesh;
  16105. private _currentLOD;
  16106. /** @hidden */
  16107. _indexInSourceMeshInstanceArray: number;
  16108. constructor(name: string, source: Mesh);
  16109. /**
  16110. * Returns the string "InstancedMesh".
  16111. */
  16112. getClassName(): string;
  16113. /** Gets the list of lights affecting that mesh */
  16114. get lightSources(): Light[];
  16115. _resyncLightSources(): void;
  16116. _resyncLightSource(light: Light): void;
  16117. _removeLightSource(light: Light, dispose: boolean): void;
  16118. /**
  16119. * If the source mesh receives shadows
  16120. */
  16121. get receiveShadows(): boolean;
  16122. /**
  16123. * The material of the source mesh
  16124. */
  16125. get material(): Nullable<Material>;
  16126. /**
  16127. * Visibility of the source mesh
  16128. */
  16129. get visibility(): number;
  16130. /**
  16131. * Skeleton of the source mesh
  16132. */
  16133. get skeleton(): Nullable<Skeleton>;
  16134. /**
  16135. * Rendering ground id of the source mesh
  16136. */
  16137. get renderingGroupId(): number;
  16138. set renderingGroupId(value: number);
  16139. /**
  16140. * Returns the total number of vertices (integer).
  16141. */
  16142. getTotalVertices(): number;
  16143. /**
  16144. * Returns a positive integer : the total number of indices in this mesh geometry.
  16145. * @returns the numner of indices or zero if the mesh has no geometry.
  16146. */
  16147. getTotalIndices(): number;
  16148. /**
  16149. * The source mesh of the instance
  16150. */
  16151. get sourceMesh(): Mesh;
  16152. /**
  16153. * Creates a new InstancedMesh object from the mesh model.
  16154. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16155. * @param name defines the name of the new instance
  16156. * @returns a new InstancedMesh
  16157. */
  16158. createInstance(name: string): InstancedMesh;
  16159. /**
  16160. * Is this node ready to be used/rendered
  16161. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16162. * @return {boolean} is it ready
  16163. */
  16164. isReady(completeCheck?: boolean): boolean;
  16165. /**
  16166. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16167. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16168. * @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.
  16169. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16170. */
  16171. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16172. /**
  16173. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16174. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16175. * The `data` are either a numeric array either a Float32Array.
  16176. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16177. * 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).
  16178. * Note that a new underlying VertexBuffer object is created each call.
  16179. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16180. *
  16181. * Possible `kind` values :
  16182. * - VertexBuffer.PositionKind
  16183. * - VertexBuffer.UVKind
  16184. * - VertexBuffer.UV2Kind
  16185. * - VertexBuffer.UV3Kind
  16186. * - VertexBuffer.UV4Kind
  16187. * - VertexBuffer.UV5Kind
  16188. * - VertexBuffer.UV6Kind
  16189. * - VertexBuffer.ColorKind
  16190. * - VertexBuffer.MatricesIndicesKind
  16191. * - VertexBuffer.MatricesIndicesExtraKind
  16192. * - VertexBuffer.MatricesWeightsKind
  16193. * - VertexBuffer.MatricesWeightsExtraKind
  16194. *
  16195. * Returns the Mesh.
  16196. */
  16197. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16198. /**
  16199. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16200. * If the mesh has no geometry, it is simply returned as it is.
  16201. * The `data` are either a numeric array either a Float32Array.
  16202. * No new underlying VertexBuffer object is created.
  16203. * 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.
  16204. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16205. *
  16206. * Possible `kind` values :
  16207. * - VertexBuffer.PositionKind
  16208. * - VertexBuffer.UVKind
  16209. * - VertexBuffer.UV2Kind
  16210. * - VertexBuffer.UV3Kind
  16211. * - VertexBuffer.UV4Kind
  16212. * - VertexBuffer.UV5Kind
  16213. * - VertexBuffer.UV6Kind
  16214. * - VertexBuffer.ColorKind
  16215. * - VertexBuffer.MatricesIndicesKind
  16216. * - VertexBuffer.MatricesIndicesExtraKind
  16217. * - VertexBuffer.MatricesWeightsKind
  16218. * - VertexBuffer.MatricesWeightsExtraKind
  16219. *
  16220. * Returns the Mesh.
  16221. */
  16222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16223. /**
  16224. * Sets the mesh indices.
  16225. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16226. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16227. * This method creates a new index buffer each call.
  16228. * Returns the Mesh.
  16229. */
  16230. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16231. /**
  16232. * Boolean : True if the mesh owns the requested kind of data.
  16233. */
  16234. isVerticesDataPresent(kind: string): boolean;
  16235. /**
  16236. * Returns an array of indices (IndicesArray).
  16237. */
  16238. getIndices(): Nullable<IndicesArray>;
  16239. get _positions(): Nullable<Vector3[]>;
  16240. /**
  16241. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16242. * This means the mesh underlying bounding box and sphere are recomputed.
  16243. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16244. * @returns the current mesh
  16245. */
  16246. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16247. /** @hidden */
  16248. _preActivate(): InstancedMesh;
  16249. /** @hidden */
  16250. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16251. /** @hidden */
  16252. _postActivate(): void;
  16253. getWorldMatrix(): Matrix;
  16254. get isAnInstance(): boolean;
  16255. /**
  16256. * Returns the current associated LOD AbstractMesh.
  16257. */
  16258. getLOD(camera: Camera): AbstractMesh;
  16259. /** @hidden */
  16260. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16261. /** @hidden */
  16262. _syncSubMeshes(): InstancedMesh;
  16263. /** @hidden */
  16264. _generatePointsArray(): boolean;
  16265. /**
  16266. * Creates a new InstancedMesh from the current mesh.
  16267. * - name (string) : the cloned mesh name
  16268. * - newParent (optional Node) : the optional Node to parent the clone to.
  16269. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16270. *
  16271. * Returns the clone.
  16272. */
  16273. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16274. /**
  16275. * Disposes the InstancedMesh.
  16276. * Returns nothing.
  16277. */
  16278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16279. }
  16280. interface Mesh {
  16281. /**
  16282. * Register a custom buffer that will be instanced
  16283. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16284. * @param kind defines the buffer kind
  16285. * @param stride defines the stride in floats
  16286. */
  16287. registerInstancedBuffer(kind: string, stride: number): void;
  16288. /**
  16289. * true to use the edge renderer for all instances of this mesh
  16290. */
  16291. edgesShareWithInstances: boolean;
  16292. /** @hidden */
  16293. _userInstancedBuffersStorage: {
  16294. data: {
  16295. [key: string]: Float32Array;
  16296. };
  16297. sizes: {
  16298. [key: string]: number;
  16299. };
  16300. vertexBuffers: {
  16301. [key: string]: Nullable<VertexBuffer>;
  16302. };
  16303. strides: {
  16304. [key: string]: number;
  16305. };
  16306. };
  16307. }
  16308. interface AbstractMesh {
  16309. /**
  16310. * Object used to store instanced buffers defined by user
  16311. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16312. */
  16313. instancedBuffers: {
  16314. [key: string]: any;
  16315. };
  16316. }
  16317. }
  16318. declare module BABYLON {
  16319. /**
  16320. * Defines the options associated with the creation of a shader material.
  16321. */
  16322. export interface IShaderMaterialOptions {
  16323. /**
  16324. * Does the material work in alpha blend mode
  16325. */
  16326. needAlphaBlending: boolean;
  16327. /**
  16328. * Does the material work in alpha test mode
  16329. */
  16330. needAlphaTesting: boolean;
  16331. /**
  16332. * The list of attribute names used in the shader
  16333. */
  16334. attributes: string[];
  16335. /**
  16336. * The list of unifrom names used in the shader
  16337. */
  16338. uniforms: string[];
  16339. /**
  16340. * The list of UBO names used in the shader
  16341. */
  16342. uniformBuffers: string[];
  16343. /**
  16344. * The list of sampler names used in the shader
  16345. */
  16346. samplers: string[];
  16347. /**
  16348. * The list of defines used in the shader
  16349. */
  16350. defines: string[];
  16351. }
  16352. /**
  16353. * 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.
  16354. *
  16355. * This returned material effects how the mesh will look based on the code in the shaders.
  16356. *
  16357. * @see https://doc.babylonjs.com/how_to/shader_material
  16358. */
  16359. export class ShaderMaterial extends Material {
  16360. private _shaderPath;
  16361. private _options;
  16362. private _textures;
  16363. private _textureArrays;
  16364. private _floats;
  16365. private _ints;
  16366. private _floatsArrays;
  16367. private _colors3;
  16368. private _colors3Arrays;
  16369. private _colors4;
  16370. private _colors4Arrays;
  16371. private _vectors2;
  16372. private _vectors3;
  16373. private _vectors4;
  16374. private _matrices;
  16375. private _matrixArrays;
  16376. private _matrices3x3;
  16377. private _matrices2x2;
  16378. private _vectors2Arrays;
  16379. private _vectors3Arrays;
  16380. private _vectors4Arrays;
  16381. private _cachedWorldViewMatrix;
  16382. private _cachedWorldViewProjectionMatrix;
  16383. private _renderId;
  16384. private _multiview;
  16385. private _cachedDefines;
  16386. /** Define the Url to load snippets */
  16387. static SnippetUrl: string;
  16388. /** Snippet ID if the material was created from the snippet server */
  16389. snippetId: string;
  16390. /**
  16391. * Instantiate a new shader material.
  16392. * 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.
  16393. * This returned material effects how the mesh will look based on the code in the shaders.
  16394. * @see https://doc.babylonjs.com/how_to/shader_material
  16395. * @param name Define the name of the material in the scene
  16396. * @param scene Define the scene the material belongs to
  16397. * @param shaderPath Defines the route to the shader code in one of three ways:
  16398. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16399. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16400. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16401. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16402. * @param options Define the options used to create the shader
  16403. */
  16404. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16405. /**
  16406. * Gets the shader path used to define the shader code
  16407. * It can be modified to trigger a new compilation
  16408. */
  16409. get shaderPath(): any;
  16410. /**
  16411. * Sets the shader path used to define the shader code
  16412. * It can be modified to trigger a new compilation
  16413. */
  16414. set shaderPath(shaderPath: any);
  16415. /**
  16416. * Gets the options used to compile the shader.
  16417. * They can be modified to trigger a new compilation
  16418. */
  16419. get options(): IShaderMaterialOptions;
  16420. /**
  16421. * Gets the current class name of the material e.g. "ShaderMaterial"
  16422. * Mainly use in serialization.
  16423. * @returns the class name
  16424. */
  16425. getClassName(): string;
  16426. /**
  16427. * Specifies if the material will require alpha blending
  16428. * @returns a boolean specifying if alpha blending is needed
  16429. */
  16430. needAlphaBlending(): boolean;
  16431. /**
  16432. * Specifies if this material should be rendered in alpha test mode
  16433. * @returns a boolean specifying if an alpha test is needed.
  16434. */
  16435. needAlphaTesting(): boolean;
  16436. private _checkUniform;
  16437. /**
  16438. * Set a texture in the shader.
  16439. * @param name Define the name of the uniform samplers as defined in the shader
  16440. * @param texture Define the texture to bind to this sampler
  16441. * @return the material itself allowing "fluent" like uniform updates
  16442. */
  16443. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16444. /**
  16445. * Set a texture array in the shader.
  16446. * @param name Define the name of the uniform sampler array as defined in the shader
  16447. * @param textures Define the list of textures to bind to this sampler
  16448. * @return the material itself allowing "fluent" like uniform updates
  16449. */
  16450. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16451. /**
  16452. * Set a float in the shader.
  16453. * @param name Define the name of the uniform as defined in the shader
  16454. * @param value Define the value to give to the uniform
  16455. * @return the material itself allowing "fluent" like uniform updates
  16456. */
  16457. setFloat(name: string, value: number): ShaderMaterial;
  16458. /**
  16459. * Set a int in the shader.
  16460. * @param name Define the name of the uniform as defined in the shader
  16461. * @param value Define the value to give to the uniform
  16462. * @return the material itself allowing "fluent" like uniform updates
  16463. */
  16464. setInt(name: string, value: number): ShaderMaterial;
  16465. /**
  16466. * Set an array of floats in the shader.
  16467. * @param name Define the name of the uniform as defined in the shader
  16468. * @param value Define the value to give to the uniform
  16469. * @return the material itself allowing "fluent" like uniform updates
  16470. */
  16471. setFloats(name: string, value: number[]): ShaderMaterial;
  16472. /**
  16473. * Set a vec3 in the shader from a Color3.
  16474. * @param name Define the name of the uniform as defined in the shader
  16475. * @param value Define the value to give to the uniform
  16476. * @return the material itself allowing "fluent" like uniform updates
  16477. */
  16478. setColor3(name: string, value: Color3): ShaderMaterial;
  16479. /**
  16480. * Set a vec3 array in the shader from a Color3 array.
  16481. * @param name Define the name of the uniform as defined in the shader
  16482. * @param value Define the value to give to the uniform
  16483. * @return the material itself allowing "fluent" like uniform updates
  16484. */
  16485. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16486. /**
  16487. * Set a vec4 in the shader from a Color4.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the material itself allowing "fluent" like uniform updates
  16491. */
  16492. setColor4(name: string, value: Color4): ShaderMaterial;
  16493. /**
  16494. * Set a vec4 array in the shader from a Color4 array.
  16495. * @param name Define the name of the uniform as defined in the shader
  16496. * @param value Define the value to give to the uniform
  16497. * @return the material itself allowing "fluent" like uniform updates
  16498. */
  16499. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16500. /**
  16501. * Set a vec2 in the shader from a Vector2.
  16502. * @param name Define the name of the uniform as defined in the shader
  16503. * @param value Define the value to give to the uniform
  16504. * @return the material itself allowing "fluent" like uniform updates
  16505. */
  16506. setVector2(name: string, value: Vector2): ShaderMaterial;
  16507. /**
  16508. * Set a vec3 in the shader from a Vector3.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the material itself allowing "fluent" like uniform updates
  16512. */
  16513. setVector3(name: string, value: Vector3): ShaderMaterial;
  16514. /**
  16515. * Set a vec4 in the shader from a Vector4.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the material itself allowing "fluent" like uniform updates
  16519. */
  16520. setVector4(name: string, value: Vector4): ShaderMaterial;
  16521. /**
  16522. * Set a mat4 in the shader from a Matrix.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the material itself allowing "fluent" like uniform updates
  16526. */
  16527. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16528. /**
  16529. * Set a float32Array in the shader from a matrix array.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the material itself allowing "fluent" like uniform updates
  16533. */
  16534. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16535. /**
  16536. * Set a mat3 in the shader from a Float32Array.
  16537. * @param name Define the name of the uniform as defined in the shader
  16538. * @param value Define the value to give to the uniform
  16539. * @return the material itself allowing "fluent" like uniform updates
  16540. */
  16541. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16542. /**
  16543. * Set a mat2 in the shader from a Float32Array.
  16544. * @param name Define the name of the uniform as defined in the shader
  16545. * @param value Define the value to give to the uniform
  16546. * @return the material itself allowing "fluent" like uniform updates
  16547. */
  16548. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16549. /**
  16550. * Set a vec2 array in the shader from a number array.
  16551. * @param name Define the name of the uniform as defined in the shader
  16552. * @param value Define the value to give to the uniform
  16553. * @return the material itself allowing "fluent" like uniform updates
  16554. */
  16555. setArray2(name: string, value: number[]): ShaderMaterial;
  16556. /**
  16557. * Set a vec3 array in the shader from a number array.
  16558. * @param name Define the name of the uniform as defined in the shader
  16559. * @param value Define the value to give to the uniform
  16560. * @return the material itself allowing "fluent" like uniform updates
  16561. */
  16562. setArray3(name: string, value: number[]): ShaderMaterial;
  16563. /**
  16564. * Set a vec4 array in the shader from a number array.
  16565. * @param name Define the name of the uniform as defined in the shader
  16566. * @param value Define the value to give to the uniform
  16567. * @return the material itself allowing "fluent" like uniform updates
  16568. */
  16569. setArray4(name: string, value: number[]): ShaderMaterial;
  16570. private _checkCache;
  16571. /**
  16572. * Specifies that the submesh is ready to be used
  16573. * @param mesh defines the mesh to check
  16574. * @param subMesh defines which submesh to check
  16575. * @param useInstances specifies that instances should be used
  16576. * @returns a boolean indicating that the submesh is ready or not
  16577. */
  16578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16579. /**
  16580. * Checks if the material is ready to render the requested mesh
  16581. * @param mesh Define the mesh to render
  16582. * @param useInstances Define whether or not the material is used with instances
  16583. * @returns true if ready, otherwise false
  16584. */
  16585. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16586. /**
  16587. * Binds the world matrix to the material
  16588. * @param world defines the world transformation matrix
  16589. * @param effectOverride - If provided, use this effect instead of internal effect
  16590. */
  16591. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16592. /**
  16593. * Binds the submesh to this material by preparing the effect and shader to draw
  16594. * @param world defines the world transformation matrix
  16595. * @param mesh defines the mesh containing the submesh
  16596. * @param subMesh defines the submesh to bind the material to
  16597. */
  16598. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16599. /**
  16600. * Binds the material to the mesh
  16601. * @param world defines the world transformation matrix
  16602. * @param mesh defines the mesh to bind the material to
  16603. * @param effectOverride - If provided, use this effect instead of internal effect
  16604. */
  16605. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16606. protected _afterBind(mesh?: Mesh): void;
  16607. /**
  16608. * Gets the active textures from the material
  16609. * @returns an array of textures
  16610. */
  16611. getActiveTextures(): BaseTexture[];
  16612. /**
  16613. * Specifies if the material uses a texture
  16614. * @param texture defines the texture to check against the material
  16615. * @returns a boolean specifying if the material uses the texture
  16616. */
  16617. hasTexture(texture: BaseTexture): boolean;
  16618. /**
  16619. * Makes a duplicate of the material, and gives it a new name
  16620. * @param name defines the new name for the duplicated material
  16621. * @returns the cloned material
  16622. */
  16623. clone(name: string): ShaderMaterial;
  16624. /**
  16625. * Disposes the material
  16626. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16627. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16628. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16629. */
  16630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16631. /**
  16632. * Serializes this material in a JSON representation
  16633. * @returns the serialized material object
  16634. */
  16635. serialize(): any;
  16636. /**
  16637. * Creates a shader material from parsed shader material data
  16638. * @param source defines the JSON represnetation of the material
  16639. * @param scene defines the hosting scene
  16640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16641. * @returns a new material
  16642. */
  16643. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16644. /**
  16645. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16646. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16647. * @param url defines the url to load from
  16648. * @param scene defines the hosting scene
  16649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16650. * @returns a promise that will resolve to the new ShaderMaterial
  16651. */
  16652. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16653. /**
  16654. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16655. * @param snippetId defines the snippet to load
  16656. * @param scene defines the hosting scene
  16657. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16658. * @returns a promise that will resolve to the new ShaderMaterial
  16659. */
  16660. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16661. }
  16662. }
  16663. declare module BABYLON {
  16664. /** @hidden */
  16665. export var colorPixelShader: {
  16666. name: string;
  16667. shader: string;
  16668. };
  16669. }
  16670. declare module BABYLON {
  16671. /** @hidden */
  16672. export var colorVertexShader: {
  16673. name: string;
  16674. shader: string;
  16675. };
  16676. }
  16677. declare module BABYLON {
  16678. /**
  16679. * Line mesh
  16680. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16681. */
  16682. export class LinesMesh extends Mesh {
  16683. /**
  16684. * If vertex color should be applied to the mesh
  16685. */
  16686. readonly useVertexColor?: boolean | undefined;
  16687. /**
  16688. * If vertex alpha should be applied to the mesh
  16689. */
  16690. readonly useVertexAlpha?: boolean | undefined;
  16691. /**
  16692. * Color of the line (Default: White)
  16693. */
  16694. color: Color3;
  16695. /**
  16696. * Alpha of the line (Default: 1)
  16697. */
  16698. alpha: number;
  16699. /**
  16700. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16701. * This margin is expressed in world space coordinates, so its value may vary.
  16702. * Default value is 0.1
  16703. */
  16704. intersectionThreshold: number;
  16705. private _colorShader;
  16706. private color4;
  16707. /**
  16708. * Creates a new LinesMesh
  16709. * @param name defines the name
  16710. * @param scene defines the hosting scene
  16711. * @param parent defines the parent mesh if any
  16712. * @param source defines the optional source LinesMesh used to clone data from
  16713. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16714. * When false, achieved by calling a clone(), also passing False.
  16715. * This will make creation of children, recursive.
  16716. * @param useVertexColor defines if this LinesMesh supports vertex color
  16717. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16718. */
  16719. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16720. /**
  16721. * If vertex color should be applied to the mesh
  16722. */
  16723. useVertexColor?: boolean | undefined,
  16724. /**
  16725. * If vertex alpha should be applied to the mesh
  16726. */
  16727. useVertexAlpha?: boolean | undefined);
  16728. private _addClipPlaneDefine;
  16729. private _removeClipPlaneDefine;
  16730. isReady(): boolean;
  16731. /**
  16732. * Returns the string "LineMesh"
  16733. */
  16734. getClassName(): string;
  16735. /**
  16736. * @hidden
  16737. */
  16738. get material(): Material;
  16739. /**
  16740. * @hidden
  16741. */
  16742. set material(value: Material);
  16743. /**
  16744. * @hidden
  16745. */
  16746. get checkCollisions(): boolean;
  16747. /** @hidden */
  16748. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16749. /** @hidden */
  16750. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16751. /**
  16752. * Disposes of the line mesh
  16753. * @param doNotRecurse If children should be disposed
  16754. */
  16755. dispose(doNotRecurse?: boolean): void;
  16756. /**
  16757. * Returns a new LineMesh object cloned from the current one.
  16758. */
  16759. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16760. /**
  16761. * Creates a new InstancedLinesMesh object from the mesh model.
  16762. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16763. * @param name defines the name of the new instance
  16764. * @returns a new InstancedLinesMesh
  16765. */
  16766. createInstance(name: string): InstancedLinesMesh;
  16767. }
  16768. /**
  16769. * Creates an instance based on a source LinesMesh
  16770. */
  16771. export class InstancedLinesMesh extends InstancedMesh {
  16772. /**
  16773. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16774. * This margin is expressed in world space coordinates, so its value may vary.
  16775. * Initilized with the intersectionThreshold value of the source LinesMesh
  16776. */
  16777. intersectionThreshold: number;
  16778. constructor(name: string, source: LinesMesh);
  16779. /**
  16780. * Returns the string "InstancedLinesMesh".
  16781. */
  16782. getClassName(): string;
  16783. }
  16784. }
  16785. declare module BABYLON {
  16786. /** @hidden */
  16787. export var linePixelShader: {
  16788. name: string;
  16789. shader: string;
  16790. };
  16791. }
  16792. declare module BABYLON {
  16793. /** @hidden */
  16794. export var lineVertexShader: {
  16795. name: string;
  16796. shader: string;
  16797. };
  16798. }
  16799. declare module BABYLON {
  16800. interface Scene {
  16801. /** @hidden */
  16802. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16803. }
  16804. interface AbstractMesh {
  16805. /**
  16806. * Gets the edgesRenderer associated with the mesh
  16807. */
  16808. edgesRenderer: Nullable<EdgesRenderer>;
  16809. }
  16810. interface LinesMesh {
  16811. /**
  16812. * Enables the edge rendering mode on the mesh.
  16813. * This mode makes the mesh edges visible
  16814. * @param epsilon defines the maximal distance between two angles to detect a face
  16815. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16816. * @returns the currentAbstractMesh
  16817. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16818. */
  16819. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16820. }
  16821. interface InstancedLinesMesh {
  16822. /**
  16823. * Enables the edge rendering mode on the mesh.
  16824. * This mode makes the mesh edges visible
  16825. * @param epsilon defines the maximal distance between two angles to detect a face
  16826. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16827. * @returns the current InstancedLinesMesh
  16828. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16829. */
  16830. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16831. }
  16832. /**
  16833. * Defines the minimum contract an Edges renderer should follow.
  16834. */
  16835. export interface IEdgesRenderer extends IDisposable {
  16836. /**
  16837. * Gets or sets a boolean indicating if the edgesRenderer is active
  16838. */
  16839. isEnabled: boolean;
  16840. /**
  16841. * Renders the edges of the attached mesh,
  16842. */
  16843. render(): void;
  16844. /**
  16845. * Checks wether or not the edges renderer is ready to render.
  16846. * @return true if ready, otherwise false.
  16847. */
  16848. isReady(): boolean;
  16849. /**
  16850. * List of instances to render in case the source mesh has instances
  16851. */
  16852. customInstances: SmartArray<Matrix>;
  16853. }
  16854. /**
  16855. * Defines the additional options of the edges renderer
  16856. */
  16857. export interface IEdgesRendererOptions {
  16858. /**
  16859. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16860. * If not defined, the default value is true
  16861. */
  16862. useAlternateEdgeFinder?: boolean;
  16863. /**
  16864. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16865. * If not defined, the default value is true.
  16866. * 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)
  16867. * This option is used only if useAlternateEdgeFinder = true
  16868. */
  16869. useFastVertexMerger?: boolean;
  16870. /**
  16871. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16872. * The default value is 1e-6
  16873. * This option is used only if useAlternateEdgeFinder = true
  16874. */
  16875. epsilonVertexMerge?: number;
  16876. /**
  16877. * 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
  16878. * 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.
  16879. * This option is used only if useAlternateEdgeFinder = true
  16880. */
  16881. applyTessellation?: boolean;
  16882. /**
  16883. * 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
  16884. * The default value is 1e-6
  16885. * This option is used only if useAlternateEdgeFinder = true
  16886. */
  16887. epsilonVertexAligned?: number;
  16888. }
  16889. /**
  16890. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16891. */
  16892. export class EdgesRenderer implements IEdgesRenderer {
  16893. /**
  16894. * Define the size of the edges with an orthographic camera
  16895. */
  16896. edgesWidthScalerForOrthographic: number;
  16897. /**
  16898. * Define the size of the edges with a perspective camera
  16899. */
  16900. edgesWidthScalerForPerspective: number;
  16901. protected _source: AbstractMesh;
  16902. protected _linesPositions: number[];
  16903. protected _linesNormals: number[];
  16904. protected _linesIndices: number[];
  16905. protected _epsilon: number;
  16906. protected _indicesCount: number;
  16907. protected _lineShader: ShaderMaterial;
  16908. protected _ib: DataBuffer;
  16909. protected _buffers: {
  16910. [key: string]: Nullable<VertexBuffer>;
  16911. };
  16912. protected _buffersForInstances: {
  16913. [key: string]: Nullable<VertexBuffer>;
  16914. };
  16915. protected _checkVerticesInsteadOfIndices: boolean;
  16916. protected _options: Nullable<IEdgesRendererOptions>;
  16917. private _meshRebuildObserver;
  16918. private _meshDisposeObserver;
  16919. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16920. isEnabled: boolean;
  16921. /**
  16922. * List of instances to render in case the source mesh has instances
  16923. */
  16924. customInstances: SmartArray<Matrix>;
  16925. private static GetShader;
  16926. /**
  16927. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16928. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16929. * @param source Mesh used to create edges
  16930. * @param epsilon sum of angles in adjacency to check for edge
  16931. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16932. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16933. * @param options The options to apply when generating the edges
  16934. */
  16935. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16936. protected _prepareRessources(): void;
  16937. /** @hidden */
  16938. _rebuild(): void;
  16939. /**
  16940. * Releases the required resources for the edges renderer
  16941. */
  16942. dispose(): void;
  16943. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16944. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16945. /**
  16946. * Checks if the pair of p0 and p1 is en edge
  16947. * @param faceIndex
  16948. * @param edge
  16949. * @param faceNormals
  16950. * @param p0
  16951. * @param p1
  16952. * @private
  16953. */
  16954. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16955. /**
  16956. * push line into the position, normal and index buffer
  16957. * @protected
  16958. */
  16959. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16960. /**
  16961. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16962. */
  16963. private _tessellateTriangle;
  16964. private _generateEdgesLinesAlternate;
  16965. /**
  16966. * Generates lines edges from adjacencjes
  16967. * @private
  16968. */
  16969. _generateEdgesLines(): void;
  16970. /**
  16971. * Checks wether or not the edges renderer is ready to render.
  16972. * @return true if ready, otherwise false.
  16973. */
  16974. isReady(): boolean;
  16975. /**
  16976. * Renders the edges of the attached mesh,
  16977. */
  16978. render(): void;
  16979. }
  16980. /**
  16981. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16982. */
  16983. export class LineEdgesRenderer extends EdgesRenderer {
  16984. /**
  16985. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16986. * @param source LineMesh used to generate edges
  16987. * @param epsilon not important (specified angle for edge detection)
  16988. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16989. */
  16990. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16991. /**
  16992. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16993. */
  16994. _generateEdgesLines(): void;
  16995. }
  16996. }
  16997. declare module BABYLON {
  16998. /**
  16999. * This represents the object necessary to create a rendering group.
  17000. * This is exclusively used and created by the rendering manager.
  17001. * To modify the behavior, you use the available helpers in your scene or meshes.
  17002. * @hidden
  17003. */
  17004. export class RenderingGroup {
  17005. index: number;
  17006. private static _zeroVector;
  17007. private _scene;
  17008. private _opaqueSubMeshes;
  17009. private _transparentSubMeshes;
  17010. private _alphaTestSubMeshes;
  17011. private _depthOnlySubMeshes;
  17012. private _particleSystems;
  17013. private _spriteManagers;
  17014. private _opaqueSortCompareFn;
  17015. private _alphaTestSortCompareFn;
  17016. private _transparentSortCompareFn;
  17017. private _renderOpaque;
  17018. private _renderAlphaTest;
  17019. private _renderTransparent;
  17020. /** @hidden */
  17021. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17022. onBeforeTransparentRendering: () => void;
  17023. /**
  17024. * Set the opaque sort comparison function.
  17025. * If null the sub meshes will be render in the order they were created
  17026. */
  17027. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17028. /**
  17029. * Set the alpha test sort comparison function.
  17030. * If null the sub meshes will be render in the order they were created
  17031. */
  17032. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17033. /**
  17034. * Set the transparent sort comparison function.
  17035. * If null the sub meshes will be render in the order they were created
  17036. */
  17037. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17038. /**
  17039. * Creates a new rendering group.
  17040. * @param index The rendering group index
  17041. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17042. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17043. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17044. */
  17045. 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>);
  17046. /**
  17047. * Render all the sub meshes contained in the group.
  17048. * @param customRenderFunction Used to override the default render behaviour of the group.
  17049. * @returns true if rendered some submeshes.
  17050. */
  17051. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17052. /**
  17053. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17054. * @param subMeshes The submeshes to render
  17055. */
  17056. private renderOpaqueSorted;
  17057. /**
  17058. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17059. * @param subMeshes The submeshes to render
  17060. */
  17061. private renderAlphaTestSorted;
  17062. /**
  17063. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17064. * @param subMeshes The submeshes to render
  17065. */
  17066. private renderTransparentSorted;
  17067. /**
  17068. * Renders the submeshes in a specified order.
  17069. * @param subMeshes The submeshes to sort before render
  17070. * @param sortCompareFn The comparison function use to sort
  17071. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17072. * @param transparent Specifies to activate blending if true
  17073. */
  17074. private static renderSorted;
  17075. /**
  17076. * Renders the submeshes in the order they were dispatched (no sort applied).
  17077. * @param subMeshes The submeshes to render
  17078. */
  17079. private static renderUnsorted;
  17080. /**
  17081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17082. * are rendered back to front if in the same alpha index.
  17083. *
  17084. * @param a The first submesh
  17085. * @param b The second submesh
  17086. * @returns The result of the comparison
  17087. */
  17088. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17089. /**
  17090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17091. * are rendered back to front.
  17092. *
  17093. * @param a The first submesh
  17094. * @param b The second submesh
  17095. * @returns The result of the comparison
  17096. */
  17097. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17098. /**
  17099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17100. * are rendered front to back (prevent overdraw).
  17101. *
  17102. * @param a The first submesh
  17103. * @param b The second submesh
  17104. * @returns The result of the comparison
  17105. */
  17106. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17107. /**
  17108. * Resets the different lists of submeshes to prepare a new frame.
  17109. */
  17110. prepare(): void;
  17111. dispose(): void;
  17112. /**
  17113. * Inserts the submesh in its correct queue depending on its material.
  17114. * @param subMesh The submesh to dispatch
  17115. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17116. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17117. */
  17118. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17119. dispatchSprites(spriteManager: ISpriteManager): void;
  17120. dispatchParticles(particleSystem: IParticleSystem): void;
  17121. private _renderParticles;
  17122. private _renderSprites;
  17123. }
  17124. }
  17125. declare module BABYLON {
  17126. /**
  17127. * Interface describing the different options available in the rendering manager
  17128. * regarding Auto Clear between groups.
  17129. */
  17130. export interface IRenderingManagerAutoClearSetup {
  17131. /**
  17132. * Defines whether or not autoclear is enable.
  17133. */
  17134. autoClear: boolean;
  17135. /**
  17136. * Defines whether or not to autoclear the depth buffer.
  17137. */
  17138. depth: boolean;
  17139. /**
  17140. * Defines whether or not to autoclear the stencil buffer.
  17141. */
  17142. stencil: boolean;
  17143. }
  17144. /**
  17145. * This class is used by the onRenderingGroupObservable
  17146. */
  17147. export class RenderingGroupInfo {
  17148. /**
  17149. * The Scene that being rendered
  17150. */
  17151. scene: Scene;
  17152. /**
  17153. * The camera currently used for the rendering pass
  17154. */
  17155. camera: Nullable<Camera>;
  17156. /**
  17157. * The ID of the renderingGroup being processed
  17158. */
  17159. renderingGroupId: number;
  17160. }
  17161. /**
  17162. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17163. * It is enable to manage the different groups as well as the different necessary sort functions.
  17164. * This should not be used directly aside of the few static configurations
  17165. */
  17166. export class RenderingManager {
  17167. /**
  17168. * The max id used for rendering groups (not included)
  17169. */
  17170. static MAX_RENDERINGGROUPS: number;
  17171. /**
  17172. * The min id used for rendering groups (included)
  17173. */
  17174. static MIN_RENDERINGGROUPS: number;
  17175. /**
  17176. * Used to globally prevent autoclearing scenes.
  17177. */
  17178. static AUTOCLEAR: boolean;
  17179. /**
  17180. * @hidden
  17181. */
  17182. _useSceneAutoClearSetup: boolean;
  17183. private _scene;
  17184. private _renderingGroups;
  17185. private _depthStencilBufferAlreadyCleaned;
  17186. private _autoClearDepthStencil;
  17187. private _customOpaqueSortCompareFn;
  17188. private _customAlphaTestSortCompareFn;
  17189. private _customTransparentSortCompareFn;
  17190. private _renderingGroupInfo;
  17191. /**
  17192. * Instantiates a new rendering group for a particular scene
  17193. * @param scene Defines the scene the groups belongs to
  17194. */
  17195. constructor(scene: Scene);
  17196. private _clearDepthStencilBuffer;
  17197. /**
  17198. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17199. * @hidden
  17200. */
  17201. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17202. /**
  17203. * Resets the different information of the group to prepare a new frame
  17204. * @hidden
  17205. */
  17206. reset(): void;
  17207. /**
  17208. * Dispose and release the group and its associated resources.
  17209. * @hidden
  17210. */
  17211. dispose(): void;
  17212. /**
  17213. * Clear the info related to rendering groups preventing retention points during dispose.
  17214. */
  17215. freeRenderingGroups(): void;
  17216. private _prepareRenderingGroup;
  17217. /**
  17218. * Add a sprite manager to the rendering manager in order to render it this frame.
  17219. * @param spriteManager Define the sprite manager to render
  17220. */
  17221. dispatchSprites(spriteManager: ISpriteManager): void;
  17222. /**
  17223. * Add a particle system to the rendering manager in order to render it this frame.
  17224. * @param particleSystem Define the particle system to render
  17225. */
  17226. dispatchParticles(particleSystem: IParticleSystem): void;
  17227. /**
  17228. * Add a submesh to the manager in order to render it this frame
  17229. * @param subMesh The submesh to dispatch
  17230. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17231. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17232. */
  17233. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17234. /**
  17235. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17236. * This allowed control for front to back rendering or reversly depending of the special needs.
  17237. *
  17238. * @param renderingGroupId The rendering group id corresponding to its index
  17239. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17240. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17241. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17242. */
  17243. 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;
  17244. /**
  17245. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17246. *
  17247. * @param renderingGroupId The rendering group id corresponding to its index
  17248. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17249. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17250. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17251. */
  17252. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17253. /**
  17254. * Gets the current auto clear configuration for one rendering group of the rendering
  17255. * manager.
  17256. * @param index the rendering group index to get the information for
  17257. * @returns The auto clear setup for the requested rendering group
  17258. */
  17259. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17260. }
  17261. }
  17262. declare module BABYLON {
  17263. /**
  17264. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17265. */
  17266. export interface ICustomShaderOptions {
  17267. /**
  17268. * Gets or sets the custom shader name to use
  17269. */
  17270. shaderName: string;
  17271. /**
  17272. * The list of attribute names used in the shader
  17273. */
  17274. attributes?: string[];
  17275. /**
  17276. * The list of unifrom names used in the shader
  17277. */
  17278. uniforms?: string[];
  17279. /**
  17280. * The list of sampler names used in the shader
  17281. */
  17282. samplers?: string[];
  17283. /**
  17284. * The list of defines used in the shader
  17285. */
  17286. defines?: string[];
  17287. }
  17288. /**
  17289. * Interface to implement to create a shadow generator compatible with BJS.
  17290. */
  17291. export interface IShadowGenerator {
  17292. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17293. id: string;
  17294. /**
  17295. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17296. * @returns The render target texture if present otherwise, null
  17297. */
  17298. getShadowMap(): Nullable<RenderTargetTexture>;
  17299. /**
  17300. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17301. * @param subMesh The submesh we want to render in the shadow map
  17302. * @param useInstances Defines wether will draw in the map using instances
  17303. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17304. * @returns true if ready otherwise, false
  17305. */
  17306. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17307. /**
  17308. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17309. * @param defines Defines of the material we want to update
  17310. * @param lightIndex Index of the light in the enabled light list of the material
  17311. */
  17312. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17313. /**
  17314. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17315. * defined in the generator but impacting the effect).
  17316. * It implies the unifroms available on the materials are the standard BJS ones.
  17317. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17318. * @param effect The effect we are binfing the information for
  17319. */
  17320. bindShadowLight(lightIndex: string, effect: Effect): void;
  17321. /**
  17322. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17323. * (eq to shadow prjection matrix * light transform matrix)
  17324. * @returns The transform matrix used to create the shadow map
  17325. */
  17326. getTransformMatrix(): Matrix;
  17327. /**
  17328. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17329. * Cube and 2D textures for instance.
  17330. */
  17331. recreateShadowMap(): void;
  17332. /**
  17333. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17334. * @param onCompiled Callback triggered at the and of the effects compilation
  17335. * @param options Sets of optional options forcing the compilation with different modes
  17336. */
  17337. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17338. useInstances: boolean;
  17339. }>): void;
  17340. /**
  17341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17342. * @param options Sets of optional options forcing the compilation with different modes
  17343. * @returns A promise that resolves when the compilation completes
  17344. */
  17345. forceCompilationAsync(options?: Partial<{
  17346. useInstances: boolean;
  17347. }>): Promise<void>;
  17348. /**
  17349. * Serializes the shadow generator setup to a json object.
  17350. * @returns The serialized JSON object
  17351. */
  17352. serialize(): any;
  17353. /**
  17354. * Disposes the Shadow map and related Textures and effects.
  17355. */
  17356. dispose(): void;
  17357. }
  17358. /**
  17359. * Default implementation IShadowGenerator.
  17360. * This is the main object responsible of generating shadows in the framework.
  17361. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17362. */
  17363. export class ShadowGenerator implements IShadowGenerator {
  17364. /**
  17365. * Name of the shadow generator class
  17366. */
  17367. static CLASSNAME: string;
  17368. /**
  17369. * Shadow generator mode None: no filtering applied.
  17370. */
  17371. static readonly FILTER_NONE: number;
  17372. /**
  17373. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17374. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17375. */
  17376. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17377. /**
  17378. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17379. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17380. */
  17381. static readonly FILTER_POISSONSAMPLING: number;
  17382. /**
  17383. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17385. */
  17386. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17387. /**
  17388. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17389. * edge artifacts on steep falloff.
  17390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17391. */
  17392. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17393. /**
  17394. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17395. * edge artifacts on steep falloff.
  17396. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17397. */
  17398. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17399. /**
  17400. * Shadow generator mode PCF: Percentage Closer Filtering
  17401. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17402. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17403. */
  17404. static readonly FILTER_PCF: number;
  17405. /**
  17406. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17407. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17408. * Contact Hardening
  17409. */
  17410. static readonly FILTER_PCSS: number;
  17411. /**
  17412. * Reserved for PCF and PCSS
  17413. * Highest Quality.
  17414. *
  17415. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17416. *
  17417. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17418. */
  17419. static readonly QUALITY_HIGH: number;
  17420. /**
  17421. * Reserved for PCF and PCSS
  17422. * Good tradeoff for quality/perf cross devices
  17423. *
  17424. * Execute PCF on a 3*3 kernel.
  17425. *
  17426. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17427. */
  17428. static readonly QUALITY_MEDIUM: number;
  17429. /**
  17430. * Reserved for PCF and PCSS
  17431. * The lowest quality but the fastest.
  17432. *
  17433. * Execute PCF on a 1*1 kernel.
  17434. *
  17435. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17436. */
  17437. static readonly QUALITY_LOW: number;
  17438. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17439. id: string;
  17440. /** Gets or sets the custom shader name to use */
  17441. customShaderOptions: ICustomShaderOptions;
  17442. /**
  17443. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17444. */
  17445. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17446. /**
  17447. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17448. */
  17449. onAfterShadowMapRenderObservable: Observable<Effect>;
  17450. /**
  17451. * Observable triggered before a mesh is rendered in the shadow map.
  17452. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17453. */
  17454. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17455. /**
  17456. * Observable triggered after a mesh is rendered in the shadow map.
  17457. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17458. */
  17459. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17460. protected _bias: number;
  17461. /**
  17462. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17463. */
  17464. get bias(): number;
  17465. /**
  17466. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17467. */
  17468. set bias(bias: number);
  17469. protected _normalBias: number;
  17470. /**
  17471. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17472. */
  17473. get normalBias(): number;
  17474. /**
  17475. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17476. */
  17477. set normalBias(normalBias: number);
  17478. protected _blurBoxOffset: number;
  17479. /**
  17480. * Gets the blur box offset: offset applied during the blur pass.
  17481. * Only useful if useKernelBlur = false
  17482. */
  17483. get blurBoxOffset(): number;
  17484. /**
  17485. * Sets the blur box offset: offset applied during the blur pass.
  17486. * Only useful if useKernelBlur = false
  17487. */
  17488. set blurBoxOffset(value: number);
  17489. protected _blurScale: number;
  17490. /**
  17491. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17492. * 2 means half of the size.
  17493. */
  17494. get blurScale(): number;
  17495. /**
  17496. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17497. * 2 means half of the size.
  17498. */
  17499. set blurScale(value: number);
  17500. protected _blurKernel: number;
  17501. /**
  17502. * Gets the blur kernel: kernel size of the blur pass.
  17503. * Only useful if useKernelBlur = true
  17504. */
  17505. get blurKernel(): number;
  17506. /**
  17507. * Sets the blur kernel: kernel size of the blur pass.
  17508. * Only useful if useKernelBlur = true
  17509. */
  17510. set blurKernel(value: number);
  17511. protected _useKernelBlur: boolean;
  17512. /**
  17513. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17514. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17515. */
  17516. get useKernelBlur(): boolean;
  17517. /**
  17518. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17519. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17520. */
  17521. set useKernelBlur(value: boolean);
  17522. protected _depthScale: number;
  17523. /**
  17524. * Gets the depth scale used in ESM mode.
  17525. */
  17526. get depthScale(): number;
  17527. /**
  17528. * Sets the depth scale used in ESM mode.
  17529. * This can override the scale stored on the light.
  17530. */
  17531. set depthScale(value: number);
  17532. protected _validateFilter(filter: number): number;
  17533. protected _filter: number;
  17534. /**
  17535. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17536. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17537. */
  17538. get filter(): number;
  17539. /**
  17540. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17541. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17542. */
  17543. set filter(value: number);
  17544. /**
  17545. * Gets if the current filter is set to Poisson Sampling.
  17546. */
  17547. get usePoissonSampling(): boolean;
  17548. /**
  17549. * Sets the current filter to Poisson Sampling.
  17550. */
  17551. set usePoissonSampling(value: boolean);
  17552. /**
  17553. * Gets if the current filter is set to ESM.
  17554. */
  17555. get useExponentialShadowMap(): boolean;
  17556. /**
  17557. * Sets the current filter is to ESM.
  17558. */
  17559. set useExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to filtered ESM.
  17562. */
  17563. get useBlurExponentialShadowMap(): boolean;
  17564. /**
  17565. * Gets if the current filter is set to filtered ESM.
  17566. */
  17567. set useBlurExponentialShadowMap(value: boolean);
  17568. /**
  17569. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17570. * exponential to prevent steep falloff artifacts).
  17571. */
  17572. get useCloseExponentialShadowMap(): boolean;
  17573. /**
  17574. * Sets the current filter to "close ESM" (using the inverse of the
  17575. * exponential to prevent steep falloff artifacts).
  17576. */
  17577. set useCloseExponentialShadowMap(value: boolean);
  17578. /**
  17579. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17580. * exponential to prevent steep falloff artifacts).
  17581. */
  17582. get useBlurCloseExponentialShadowMap(): boolean;
  17583. /**
  17584. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17585. * exponential to prevent steep falloff artifacts).
  17586. */
  17587. set useBlurCloseExponentialShadowMap(value: boolean);
  17588. /**
  17589. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17590. */
  17591. get usePercentageCloserFiltering(): boolean;
  17592. /**
  17593. * Sets the current filter to "PCF" (percentage closer filtering).
  17594. */
  17595. set usePercentageCloserFiltering(value: boolean);
  17596. protected _filteringQuality: number;
  17597. /**
  17598. * Gets the PCF or PCSS Quality.
  17599. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17600. */
  17601. get filteringQuality(): number;
  17602. /**
  17603. * Sets the PCF or PCSS Quality.
  17604. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17605. */
  17606. set filteringQuality(filteringQuality: number);
  17607. /**
  17608. * Gets if the current filter is set to "PCSS" (contact hardening).
  17609. */
  17610. get useContactHardeningShadow(): boolean;
  17611. /**
  17612. * Sets the current filter to "PCSS" (contact hardening).
  17613. */
  17614. set useContactHardeningShadow(value: boolean);
  17615. protected _contactHardeningLightSizeUVRatio: number;
  17616. /**
  17617. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17618. * Using a ratio helps keeping shape stability independently of the map size.
  17619. *
  17620. * It does not account for the light projection as it was having too much
  17621. * instability during the light setup or during light position changes.
  17622. *
  17623. * Only valid if useContactHardeningShadow is true.
  17624. */
  17625. get contactHardeningLightSizeUVRatio(): number;
  17626. /**
  17627. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17628. * Using a ratio helps keeping shape stability independently of the map size.
  17629. *
  17630. * It does not account for the light projection as it was having too much
  17631. * instability during the light setup or during light position changes.
  17632. *
  17633. * Only valid if useContactHardeningShadow is true.
  17634. */
  17635. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17636. protected _darkness: number;
  17637. /** Gets or sets the actual darkness of a shadow */
  17638. get darkness(): number;
  17639. set darkness(value: number);
  17640. /**
  17641. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17642. * 0 means strongest and 1 would means no shadow.
  17643. * @returns the darkness.
  17644. */
  17645. getDarkness(): number;
  17646. /**
  17647. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17648. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17649. * @returns the shadow generator allowing fluent coding.
  17650. */
  17651. setDarkness(darkness: number): ShadowGenerator;
  17652. protected _transparencyShadow: boolean;
  17653. /** Gets or sets the ability to have transparent shadow */
  17654. get transparencyShadow(): boolean;
  17655. set transparencyShadow(value: boolean);
  17656. /**
  17657. * Sets the ability to have transparent shadow (boolean).
  17658. * @param transparent True if transparent else False
  17659. * @returns the shadow generator allowing fluent coding
  17660. */
  17661. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17662. /**
  17663. * Enables or disables shadows with varying strength based on the transparency
  17664. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17665. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17666. * mesh.visibility * alphaTexture.a
  17667. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17668. */
  17669. enableSoftTransparentShadow: boolean;
  17670. protected _shadowMap: Nullable<RenderTargetTexture>;
  17671. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17672. /**
  17673. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17674. * @returns The render target texture if present otherwise, null
  17675. */
  17676. getShadowMap(): Nullable<RenderTargetTexture>;
  17677. /**
  17678. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17679. * @returns The render target texture if the shadow map is present otherwise, null
  17680. */
  17681. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17682. /**
  17683. * Gets the class name of that object
  17684. * @returns "ShadowGenerator"
  17685. */
  17686. getClassName(): string;
  17687. /**
  17688. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17689. * @param mesh Mesh to add
  17690. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17691. * @returns the Shadow Generator itself
  17692. */
  17693. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17694. /**
  17695. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17696. * @param mesh Mesh to remove
  17697. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17698. * @returns the Shadow Generator itself
  17699. */
  17700. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17701. /**
  17702. * Controls the extent to which the shadows fade out at the edge of the frustum
  17703. */
  17704. frustumEdgeFalloff: number;
  17705. protected _light: IShadowLight;
  17706. /**
  17707. * Returns the associated light object.
  17708. * @returns the light generating the shadow
  17709. */
  17710. getLight(): IShadowLight;
  17711. /**
  17712. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17713. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17714. * It might on the other hand introduce peter panning.
  17715. */
  17716. forceBackFacesOnly: boolean;
  17717. protected _scene: Scene;
  17718. protected _lightDirection: Vector3;
  17719. protected _effect: Effect;
  17720. protected _viewMatrix: Matrix;
  17721. protected _projectionMatrix: Matrix;
  17722. protected _transformMatrix: Matrix;
  17723. protected _cachedPosition: Vector3;
  17724. protected _cachedDirection: Vector3;
  17725. protected _cachedDefines: string;
  17726. protected _currentRenderID: number;
  17727. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17728. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17729. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17730. protected _blurPostProcesses: PostProcess[];
  17731. protected _mapSize: number;
  17732. protected _currentFaceIndex: number;
  17733. protected _currentFaceIndexCache: number;
  17734. protected _textureType: number;
  17735. protected _defaultTextureMatrix: Matrix;
  17736. protected _storedUniqueId: Nullable<number>;
  17737. /** @hidden */
  17738. static _SceneComponentInitialization: (scene: Scene) => void;
  17739. /**
  17740. * Creates a ShadowGenerator object.
  17741. * A ShadowGenerator is the required tool to use the shadows.
  17742. * Each light casting shadows needs to use its own ShadowGenerator.
  17743. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17744. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17745. * @param light The light object generating the shadows.
  17746. * @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.
  17747. */
  17748. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17749. protected _initializeGenerator(): void;
  17750. protected _createTargetRenderTexture(): void;
  17751. protected _initializeShadowMap(): void;
  17752. protected _initializeBlurRTTAndPostProcesses(): void;
  17753. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17754. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17755. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17756. protected _applyFilterValues(): void;
  17757. /**
  17758. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17759. * @param onCompiled Callback triggered at the and of the effects compilation
  17760. * @param options Sets of optional options forcing the compilation with different modes
  17761. */
  17762. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17763. useInstances: boolean;
  17764. }>): void;
  17765. /**
  17766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17767. * @param options Sets of optional options forcing the compilation with different modes
  17768. * @returns A promise that resolves when the compilation completes
  17769. */
  17770. forceCompilationAsync(options?: Partial<{
  17771. useInstances: boolean;
  17772. }>): Promise<void>;
  17773. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17774. private _prepareShadowDefines;
  17775. /**
  17776. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17777. * @param subMesh The submesh we want to render in the shadow map
  17778. * @param useInstances Defines wether will draw in the map using instances
  17779. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17780. * @returns true if ready otherwise, false
  17781. */
  17782. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17783. /**
  17784. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17785. * @param defines Defines of the material we want to update
  17786. * @param lightIndex Index of the light in the enabled light list of the material
  17787. */
  17788. prepareDefines(defines: any, lightIndex: number): void;
  17789. /**
  17790. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17791. * defined in the generator but impacting the effect).
  17792. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17793. * @param effect The effect we are binfing the information for
  17794. */
  17795. bindShadowLight(lightIndex: string, effect: Effect): void;
  17796. /**
  17797. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17798. * (eq to shadow prjection matrix * light transform matrix)
  17799. * @returns The transform matrix used to create the shadow map
  17800. */
  17801. getTransformMatrix(): Matrix;
  17802. /**
  17803. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17804. * Cube and 2D textures for instance.
  17805. */
  17806. recreateShadowMap(): void;
  17807. protected _disposeBlurPostProcesses(): void;
  17808. protected _disposeRTTandPostProcesses(): void;
  17809. /**
  17810. * Disposes the ShadowGenerator.
  17811. * Returns nothing.
  17812. */
  17813. dispose(): void;
  17814. /**
  17815. * Serializes the shadow generator setup to a json object.
  17816. * @returns The serialized JSON object
  17817. */
  17818. serialize(): any;
  17819. /**
  17820. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17821. * @param parsedShadowGenerator The JSON object to parse
  17822. * @param scene The scene to create the shadow map for
  17823. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17824. * @returns The parsed shadow generator
  17825. */
  17826. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17827. }
  17828. }
  17829. declare module BABYLON {
  17830. /**
  17831. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17832. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17833. * 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.
  17834. */
  17835. export abstract class Light extends Node {
  17836. /**
  17837. * Falloff Default: light is falling off following the material specification:
  17838. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17839. */
  17840. static readonly FALLOFF_DEFAULT: number;
  17841. /**
  17842. * Falloff Physical: light is falling off following the inverse squared distance law.
  17843. */
  17844. static readonly FALLOFF_PHYSICAL: number;
  17845. /**
  17846. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17847. * to enhance interoperability with other engines.
  17848. */
  17849. static readonly FALLOFF_GLTF: number;
  17850. /**
  17851. * Falloff Standard: light is falling off like in the standard material
  17852. * to enhance interoperability with other materials.
  17853. */
  17854. static readonly FALLOFF_STANDARD: number;
  17855. /**
  17856. * If every light affecting the material is in this lightmapMode,
  17857. * material.lightmapTexture adds or multiplies
  17858. * (depends on material.useLightmapAsShadowmap)
  17859. * after every other light calculations.
  17860. */
  17861. static readonly LIGHTMAP_DEFAULT: number;
  17862. /**
  17863. * material.lightmapTexture as only diffuse lighting from this light
  17864. * adds only specular lighting from this light
  17865. * adds dynamic shadows
  17866. */
  17867. static readonly LIGHTMAP_SPECULAR: number;
  17868. /**
  17869. * material.lightmapTexture as only lighting
  17870. * no light calculation from this light
  17871. * only adds dynamic shadows from this light
  17872. */
  17873. static readonly LIGHTMAP_SHADOWSONLY: number;
  17874. /**
  17875. * Each light type uses the default quantity according to its type:
  17876. * point/spot lights use luminous intensity
  17877. * directional lights use illuminance
  17878. */
  17879. static readonly INTENSITYMODE_AUTOMATIC: number;
  17880. /**
  17881. * lumen (lm)
  17882. */
  17883. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17884. /**
  17885. * candela (lm/sr)
  17886. */
  17887. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17888. /**
  17889. * lux (lm/m^2)
  17890. */
  17891. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17892. /**
  17893. * nit (cd/m^2)
  17894. */
  17895. static readonly INTENSITYMODE_LUMINANCE: number;
  17896. /**
  17897. * Light type const id of the point light.
  17898. */
  17899. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17900. /**
  17901. * Light type const id of the directional light.
  17902. */
  17903. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17904. /**
  17905. * Light type const id of the spot light.
  17906. */
  17907. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17908. /**
  17909. * Light type const id of the hemispheric light.
  17910. */
  17911. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17912. /**
  17913. * Diffuse gives the basic color to an object.
  17914. */
  17915. diffuse: Color3;
  17916. /**
  17917. * Specular produces a highlight color on an object.
  17918. * Note: This is note affecting PBR materials.
  17919. */
  17920. specular: Color3;
  17921. /**
  17922. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17923. * falling off base on range or angle.
  17924. * This can be set to any values in Light.FALLOFF_x.
  17925. *
  17926. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17927. * other types of materials.
  17928. */
  17929. falloffType: number;
  17930. /**
  17931. * Strength of the light.
  17932. * Note: By default it is define in the framework own unit.
  17933. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17934. */
  17935. intensity: number;
  17936. private _range;
  17937. protected _inverseSquaredRange: number;
  17938. /**
  17939. * Defines how far from the source the light is impacting in scene units.
  17940. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17941. */
  17942. get range(): number;
  17943. /**
  17944. * Defines how far from the source the light is impacting in scene units.
  17945. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17946. */
  17947. set range(value: number);
  17948. /**
  17949. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17950. * of light.
  17951. */
  17952. private _photometricScale;
  17953. private _intensityMode;
  17954. /**
  17955. * Gets the photometric scale used to interpret the intensity.
  17956. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17957. */
  17958. get intensityMode(): number;
  17959. /**
  17960. * Sets the photometric scale used to interpret the intensity.
  17961. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17962. */
  17963. set intensityMode(value: number);
  17964. private _radius;
  17965. /**
  17966. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17967. */
  17968. get radius(): number;
  17969. /**
  17970. * sets the light radius used by PBR Materials to simulate soft area lights.
  17971. */
  17972. set radius(value: number);
  17973. private _renderPriority;
  17974. /**
  17975. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17976. * exceeding the number allowed of the materials.
  17977. */
  17978. renderPriority: number;
  17979. private _shadowEnabled;
  17980. /**
  17981. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17982. * the current shadow generator.
  17983. */
  17984. get shadowEnabled(): boolean;
  17985. /**
  17986. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17987. * the current shadow generator.
  17988. */
  17989. set shadowEnabled(value: boolean);
  17990. private _includedOnlyMeshes;
  17991. /**
  17992. * Gets the only meshes impacted by this light.
  17993. */
  17994. get includedOnlyMeshes(): AbstractMesh[];
  17995. /**
  17996. * Sets the only meshes impacted by this light.
  17997. */
  17998. set includedOnlyMeshes(value: AbstractMesh[]);
  17999. private _excludedMeshes;
  18000. /**
  18001. * Gets the meshes not impacted by this light.
  18002. */
  18003. get excludedMeshes(): AbstractMesh[];
  18004. /**
  18005. * Sets the meshes not impacted by this light.
  18006. */
  18007. set excludedMeshes(value: AbstractMesh[]);
  18008. private _excludeWithLayerMask;
  18009. /**
  18010. * Gets the layer id use to find what meshes are not impacted by the light.
  18011. * Inactive if 0
  18012. */
  18013. get excludeWithLayerMask(): number;
  18014. /**
  18015. * Sets the layer id use to find what meshes are not impacted by the light.
  18016. * Inactive if 0
  18017. */
  18018. set excludeWithLayerMask(value: number);
  18019. private _includeOnlyWithLayerMask;
  18020. /**
  18021. * Gets the layer id use to find what meshes are impacted by the light.
  18022. * Inactive if 0
  18023. */
  18024. get includeOnlyWithLayerMask(): number;
  18025. /**
  18026. * Sets the layer id use to find what meshes are impacted by the light.
  18027. * Inactive if 0
  18028. */
  18029. set includeOnlyWithLayerMask(value: number);
  18030. private _lightmapMode;
  18031. /**
  18032. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18033. */
  18034. get lightmapMode(): number;
  18035. /**
  18036. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18037. */
  18038. set lightmapMode(value: number);
  18039. /**
  18040. * Shadow generator associted to the light.
  18041. * @hidden Internal use only.
  18042. */
  18043. _shadowGenerator: Nullable<IShadowGenerator>;
  18044. /**
  18045. * @hidden Internal use only.
  18046. */
  18047. _excludedMeshesIds: string[];
  18048. /**
  18049. * @hidden Internal use only.
  18050. */
  18051. _includedOnlyMeshesIds: string[];
  18052. /**
  18053. * The current light unifom buffer.
  18054. * @hidden Internal use only.
  18055. */
  18056. _uniformBuffer: UniformBuffer;
  18057. /** @hidden */
  18058. _renderId: number;
  18059. /**
  18060. * Creates a Light object in the scene.
  18061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18062. * @param name The firendly name of the light
  18063. * @param scene The scene the light belongs too
  18064. */
  18065. constructor(name: string, scene: Scene);
  18066. protected abstract _buildUniformLayout(): void;
  18067. /**
  18068. * Sets the passed Effect "effect" with the Light information.
  18069. * @param effect The effect to update
  18070. * @param lightIndex The index of the light in the effect to update
  18071. * @returns The light
  18072. */
  18073. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18074. /**
  18075. * Sets the passed Effect "effect" with the Light textures.
  18076. * @param effect The effect to update
  18077. * @param lightIndex The index of the light in the effect to update
  18078. * @returns The light
  18079. */
  18080. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18081. /**
  18082. * Binds the lights information from the scene to the effect for the given mesh.
  18083. * @param lightIndex Light index
  18084. * @param scene The scene where the light belongs to
  18085. * @param effect The effect we are binding the data to
  18086. * @param useSpecular Defines if specular is supported
  18087. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18088. */
  18089. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18090. /**
  18091. * Sets the passed Effect "effect" with the Light information.
  18092. * @param effect The effect to update
  18093. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18094. * @returns The light
  18095. */
  18096. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18097. /**
  18098. * Returns the string "Light".
  18099. * @returns the class name
  18100. */
  18101. getClassName(): string;
  18102. /** @hidden */
  18103. readonly _isLight: boolean;
  18104. /**
  18105. * Converts the light information to a readable string for debug purpose.
  18106. * @param fullDetails Supports for multiple levels of logging within scene loading
  18107. * @returns the human readable light info
  18108. */
  18109. toString(fullDetails?: boolean): string;
  18110. /** @hidden */
  18111. protected _syncParentEnabledState(): void;
  18112. /**
  18113. * Set the enabled state of this node.
  18114. * @param value - the new enabled state
  18115. */
  18116. setEnabled(value: boolean): void;
  18117. /**
  18118. * Returns the Light associated shadow generator if any.
  18119. * @return the associated shadow generator.
  18120. */
  18121. getShadowGenerator(): Nullable<IShadowGenerator>;
  18122. /**
  18123. * Returns a Vector3, the absolute light position in the World.
  18124. * @returns the world space position of the light
  18125. */
  18126. getAbsolutePosition(): Vector3;
  18127. /**
  18128. * Specifies if the light will affect the passed mesh.
  18129. * @param mesh The mesh to test against the light
  18130. * @return true the mesh is affected otherwise, false.
  18131. */
  18132. canAffectMesh(mesh: AbstractMesh): boolean;
  18133. /**
  18134. * Sort function to order lights for rendering.
  18135. * @param a First Light object to compare to second.
  18136. * @param b Second Light object to compare first.
  18137. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18138. */
  18139. static CompareLightsPriority(a: Light, b: Light): number;
  18140. /**
  18141. * Releases resources associated with this node.
  18142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18144. */
  18145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18146. /**
  18147. * Returns the light type ID (integer).
  18148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18149. */
  18150. getTypeID(): number;
  18151. /**
  18152. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18153. * @returns the scaled intensity in intensity mode unit
  18154. */
  18155. getScaledIntensity(): number;
  18156. /**
  18157. * Returns a new Light object, named "name", from the current one.
  18158. * @param name The name of the cloned light
  18159. * @param newParent The parent of this light, if it has one
  18160. * @returns the new created light
  18161. */
  18162. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18163. /**
  18164. * Serializes the current light into a Serialization object.
  18165. * @returns the serialized object.
  18166. */
  18167. serialize(): any;
  18168. /**
  18169. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18170. * This new light is named "name" and added to the passed scene.
  18171. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18172. * @param name The friendly name of the light
  18173. * @param scene The scene the new light will belong to
  18174. * @returns the constructor function
  18175. */
  18176. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18177. /**
  18178. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18179. * @param parsedLight The JSON representation of the light
  18180. * @param scene The scene to create the parsed light in
  18181. * @returns the created light after parsing
  18182. */
  18183. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18184. private _hookArrayForExcluded;
  18185. private _hookArrayForIncludedOnly;
  18186. private _resyncMeshes;
  18187. /**
  18188. * Forces the meshes to update their light related information in their rendering used effects
  18189. * @hidden Internal Use Only
  18190. */
  18191. _markMeshesAsLightDirty(): void;
  18192. /**
  18193. * Recomputes the cached photometric scale if needed.
  18194. */
  18195. private _computePhotometricScale;
  18196. /**
  18197. * Returns the Photometric Scale according to the light type and intensity mode.
  18198. */
  18199. private _getPhotometricScale;
  18200. /**
  18201. * Reorder the light in the scene according to their defined priority.
  18202. * @hidden Internal Use Only
  18203. */
  18204. _reorderLightsInScene(): void;
  18205. /**
  18206. * Prepares the list of defines specific to the light type.
  18207. * @param defines the list of defines
  18208. * @param lightIndex defines the index of the light for the effect
  18209. */
  18210. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18211. }
  18212. }
  18213. declare module BABYLON {
  18214. /**
  18215. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18216. * This is the base of the follow, arc rotate cameras and Free camera
  18217. * @see https://doc.babylonjs.com/features/cameras
  18218. */
  18219. export class TargetCamera extends Camera {
  18220. private static _RigCamTransformMatrix;
  18221. private static _TargetTransformMatrix;
  18222. private static _TargetFocalPoint;
  18223. private _tmpUpVector;
  18224. private _tmpTargetVector;
  18225. /**
  18226. * Define the current direction the camera is moving to
  18227. */
  18228. cameraDirection: Vector3;
  18229. /**
  18230. * Define the current rotation the camera is rotating to
  18231. */
  18232. cameraRotation: Vector2;
  18233. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18234. ignoreParentScaling: boolean;
  18235. /**
  18236. * When set, the up vector of the camera will be updated by the rotation of the camera
  18237. */
  18238. updateUpVectorFromRotation: boolean;
  18239. private _tmpQuaternion;
  18240. /**
  18241. * Define the current rotation of the camera
  18242. */
  18243. rotation: Vector3;
  18244. /**
  18245. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18246. */
  18247. rotationQuaternion: Quaternion;
  18248. /**
  18249. * Define the current speed of the camera
  18250. */
  18251. speed: number;
  18252. /**
  18253. * Add constraint to the camera to prevent it to move freely in all directions and
  18254. * around all axis.
  18255. */
  18256. noRotationConstraint: boolean;
  18257. /**
  18258. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18259. * panning
  18260. */
  18261. invertRotation: boolean;
  18262. /**
  18263. * Speed multiplier for inverse camera panning
  18264. */
  18265. inverseRotationSpeed: number;
  18266. /**
  18267. * Define the current target of the camera as an object or a position.
  18268. */
  18269. lockedTarget: any;
  18270. /** @hidden */
  18271. _currentTarget: Vector3;
  18272. /** @hidden */
  18273. _initialFocalDistance: number;
  18274. /** @hidden */
  18275. _viewMatrix: Matrix;
  18276. /** @hidden */
  18277. _camMatrix: Matrix;
  18278. /** @hidden */
  18279. _cameraTransformMatrix: Matrix;
  18280. /** @hidden */
  18281. _cameraRotationMatrix: Matrix;
  18282. /** @hidden */
  18283. _referencePoint: Vector3;
  18284. /** @hidden */
  18285. _transformedReferencePoint: Vector3;
  18286. /** @hidden */
  18287. _reset: () => void;
  18288. private _defaultUp;
  18289. /**
  18290. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18291. * This is the base of the follow, arc rotate cameras and Free camera
  18292. * @see https://doc.babylonjs.com/features/cameras
  18293. * @param name Defines the name of the camera in the scene
  18294. * @param position Defines the start position of the camera in the scene
  18295. * @param scene Defines the scene the camera belongs to
  18296. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18297. */
  18298. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18299. /**
  18300. * Gets the position in front of the camera at a given distance.
  18301. * @param distance The distance from the camera we want the position to be
  18302. * @returns the position
  18303. */
  18304. getFrontPosition(distance: number): Vector3;
  18305. /** @hidden */
  18306. _getLockedTargetPosition(): Nullable<Vector3>;
  18307. private _storedPosition;
  18308. private _storedRotation;
  18309. private _storedRotationQuaternion;
  18310. /**
  18311. * Store current camera state of the camera (fov, position, rotation, etc..)
  18312. * @returns the camera
  18313. */
  18314. storeState(): Camera;
  18315. /**
  18316. * Restored camera state. You must call storeState() first
  18317. * @returns whether it was successful or not
  18318. * @hidden
  18319. */
  18320. _restoreStateValues(): boolean;
  18321. /** @hidden */
  18322. _initCache(): void;
  18323. /** @hidden */
  18324. _updateCache(ignoreParentClass?: boolean): void;
  18325. /** @hidden */
  18326. _isSynchronizedViewMatrix(): boolean;
  18327. /** @hidden */
  18328. _computeLocalCameraSpeed(): number;
  18329. /**
  18330. * Defines the target the camera should look at.
  18331. * @param target Defines the new target as a Vector or a mesh
  18332. */
  18333. setTarget(target: Vector3): void;
  18334. /**
  18335. * Return the current target position of the camera. This value is expressed in local space.
  18336. * @returns the target position
  18337. */
  18338. getTarget(): Vector3;
  18339. /** @hidden */
  18340. _decideIfNeedsToMove(): boolean;
  18341. /** @hidden */
  18342. _updatePosition(): void;
  18343. /** @hidden */
  18344. _checkInputs(): void;
  18345. protected _updateCameraRotationMatrix(): void;
  18346. /**
  18347. * 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)
  18348. * @returns the current camera
  18349. */
  18350. private _rotateUpVectorWithCameraRotationMatrix;
  18351. private _cachedRotationZ;
  18352. private _cachedQuaternionRotationZ;
  18353. /** @hidden */
  18354. _getViewMatrix(): Matrix;
  18355. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18356. /**
  18357. * @hidden
  18358. */
  18359. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18360. /**
  18361. * @hidden
  18362. */
  18363. _updateRigCameras(): void;
  18364. private _getRigCamPositionAndTarget;
  18365. /**
  18366. * Gets the current object class name.
  18367. * @return the class name
  18368. */
  18369. getClassName(): string;
  18370. }
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * Gather the list of keyboard event types as constants.
  18375. */
  18376. export class KeyboardEventTypes {
  18377. /**
  18378. * The keydown event is fired when a key becomes active (pressed).
  18379. */
  18380. static readonly KEYDOWN: number;
  18381. /**
  18382. * The keyup event is fired when a key has been released.
  18383. */
  18384. static readonly KEYUP: number;
  18385. }
  18386. /**
  18387. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18388. */
  18389. export class KeyboardInfo {
  18390. /**
  18391. * Defines the type of event (KeyboardEventTypes)
  18392. */
  18393. type: number;
  18394. /**
  18395. * Defines the related dom event
  18396. */
  18397. event: KeyboardEvent;
  18398. /**
  18399. * Instantiates a new keyboard info.
  18400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18401. * @param type Defines the type of event (KeyboardEventTypes)
  18402. * @param event Defines the related dom event
  18403. */
  18404. constructor(
  18405. /**
  18406. * Defines the type of event (KeyboardEventTypes)
  18407. */
  18408. type: number,
  18409. /**
  18410. * Defines the related dom event
  18411. */
  18412. event: KeyboardEvent);
  18413. }
  18414. /**
  18415. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18416. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18417. */
  18418. export class KeyboardInfoPre extends KeyboardInfo {
  18419. /**
  18420. * Defines the type of event (KeyboardEventTypes)
  18421. */
  18422. type: number;
  18423. /**
  18424. * Defines the related dom event
  18425. */
  18426. event: KeyboardEvent;
  18427. /**
  18428. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18429. */
  18430. skipOnPointerObservable: boolean;
  18431. /**
  18432. * Instantiates a new keyboard pre info.
  18433. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18434. * @param type Defines the type of event (KeyboardEventTypes)
  18435. * @param event Defines the related dom event
  18436. */
  18437. constructor(
  18438. /**
  18439. * Defines the type of event (KeyboardEventTypes)
  18440. */
  18441. type: number,
  18442. /**
  18443. * Defines the related dom event
  18444. */
  18445. event: KeyboardEvent);
  18446. }
  18447. }
  18448. declare module BABYLON {
  18449. /**
  18450. * Manage the keyboard inputs to control the movement of a free camera.
  18451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18452. */
  18453. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18454. /**
  18455. * Defines the camera the input is attached to.
  18456. */
  18457. camera: FreeCamera;
  18458. /**
  18459. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18460. */
  18461. keysUp: number[];
  18462. /**
  18463. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18464. */
  18465. keysUpward: number[];
  18466. /**
  18467. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18468. */
  18469. keysDown: number[];
  18470. /**
  18471. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18472. */
  18473. keysDownward: number[];
  18474. /**
  18475. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18476. */
  18477. keysLeft: number[];
  18478. /**
  18479. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18480. */
  18481. keysRight: number[];
  18482. private _keys;
  18483. private _onCanvasBlurObserver;
  18484. private _onKeyboardObserver;
  18485. private _engine;
  18486. private _scene;
  18487. /**
  18488. * Attach the input controls to a specific dom element to get the input from.
  18489. * @param element Defines the element the controls should be listened from
  18490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18491. */
  18492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18493. /**
  18494. * Detach the current controls from the specified dom element.
  18495. * @param element Defines the element to stop listening the inputs from
  18496. */
  18497. detachControl(element: Nullable<HTMLElement>): void;
  18498. /**
  18499. * Update the current camera state depending on the inputs that have been used this frame.
  18500. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18501. */
  18502. checkInputs(): void;
  18503. /**
  18504. * Gets the class name of the current intput.
  18505. * @returns the class name
  18506. */
  18507. getClassName(): string;
  18508. /** @hidden */
  18509. _onLostFocus(): void;
  18510. /**
  18511. * Get the friendly name associated with the input class.
  18512. * @returns the input friendly name
  18513. */
  18514. getSimpleName(): string;
  18515. }
  18516. }
  18517. declare module BABYLON {
  18518. /**
  18519. * Gather the list of pointer event types as constants.
  18520. */
  18521. export class PointerEventTypes {
  18522. /**
  18523. * 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.
  18524. */
  18525. static readonly POINTERDOWN: number;
  18526. /**
  18527. * The pointerup event is fired when a pointer is no longer active.
  18528. */
  18529. static readonly POINTERUP: number;
  18530. /**
  18531. * The pointermove event is fired when a pointer changes coordinates.
  18532. */
  18533. static readonly POINTERMOVE: number;
  18534. /**
  18535. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18536. */
  18537. static readonly POINTERWHEEL: number;
  18538. /**
  18539. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18540. */
  18541. static readonly POINTERPICK: number;
  18542. /**
  18543. * The pointertap event is fired when a the object has been touched and released without drag.
  18544. */
  18545. static readonly POINTERTAP: number;
  18546. /**
  18547. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18548. */
  18549. static readonly POINTERDOUBLETAP: number;
  18550. }
  18551. /**
  18552. * Base class of pointer info types.
  18553. */
  18554. export class PointerInfoBase {
  18555. /**
  18556. * Defines the type of event (PointerEventTypes)
  18557. */
  18558. type: number;
  18559. /**
  18560. * Defines the related dom event
  18561. */
  18562. event: PointerEvent | MouseWheelEvent;
  18563. /**
  18564. * Instantiates the base class of pointers info.
  18565. * @param type Defines the type of event (PointerEventTypes)
  18566. * @param event Defines the related dom event
  18567. */
  18568. constructor(
  18569. /**
  18570. * Defines the type of event (PointerEventTypes)
  18571. */
  18572. type: number,
  18573. /**
  18574. * Defines the related dom event
  18575. */
  18576. event: PointerEvent | MouseWheelEvent);
  18577. }
  18578. /**
  18579. * This class is used to store pointer related info for the onPrePointerObservable event.
  18580. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18581. */
  18582. export class PointerInfoPre extends PointerInfoBase {
  18583. /**
  18584. * Ray from a pointer if availible (eg. 6dof controller)
  18585. */
  18586. ray: Nullable<Ray>;
  18587. /**
  18588. * Defines the local position of the pointer on the canvas.
  18589. */
  18590. localPosition: Vector2;
  18591. /**
  18592. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18593. */
  18594. skipOnPointerObservable: boolean;
  18595. /**
  18596. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18597. * @param type Defines the type of event (PointerEventTypes)
  18598. * @param event Defines the related dom event
  18599. * @param localX Defines the local x coordinates of the pointer when the event occured
  18600. * @param localY Defines the local y coordinates of the pointer when the event occured
  18601. */
  18602. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18603. }
  18604. /**
  18605. * This type contains all the data related to a pointer event in Babylon.js.
  18606. * 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.
  18607. */
  18608. export class PointerInfo extends PointerInfoBase {
  18609. /**
  18610. * Defines the picking info associated to the info (if any)\
  18611. */
  18612. pickInfo: Nullable<PickingInfo>;
  18613. /**
  18614. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18615. * @param type Defines the type of event (PointerEventTypes)
  18616. * @param event Defines the related dom event
  18617. * @param pickInfo Defines the picking info associated to the info (if any)\
  18618. */
  18619. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18620. /**
  18621. * Defines the picking info associated to the info (if any)\
  18622. */
  18623. pickInfo: Nullable<PickingInfo>);
  18624. }
  18625. /**
  18626. * Data relating to a touch event on the screen.
  18627. */
  18628. export interface PointerTouch {
  18629. /**
  18630. * X coordinate of touch.
  18631. */
  18632. x: number;
  18633. /**
  18634. * Y coordinate of touch.
  18635. */
  18636. y: number;
  18637. /**
  18638. * Id of touch. Unique for each finger.
  18639. */
  18640. pointerId: number;
  18641. /**
  18642. * Event type passed from DOM.
  18643. */
  18644. type: any;
  18645. }
  18646. }
  18647. declare module BABYLON {
  18648. /**
  18649. * Manage the mouse inputs to control the movement of a free camera.
  18650. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18651. */
  18652. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18653. /**
  18654. * Define if touch is enabled in the mouse input
  18655. */
  18656. touchEnabled: boolean;
  18657. /**
  18658. * Defines the camera the input is attached to.
  18659. */
  18660. camera: FreeCamera;
  18661. /**
  18662. * Defines the buttons associated with the input to handle camera move.
  18663. */
  18664. buttons: number[];
  18665. /**
  18666. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18667. */
  18668. angularSensibility: number;
  18669. private _pointerInput;
  18670. private _onMouseMove;
  18671. private _observer;
  18672. private previousPosition;
  18673. /**
  18674. * Observable for when a pointer move event occurs containing the move offset
  18675. */
  18676. onPointerMovedObservable: Observable<{
  18677. offsetX: number;
  18678. offsetY: number;
  18679. }>;
  18680. /**
  18681. * @hidden
  18682. * If the camera should be rotated automatically based on pointer movement
  18683. */
  18684. _allowCameraRotation: boolean;
  18685. /**
  18686. * Manage the mouse inputs to control the movement of a free camera.
  18687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18688. * @param touchEnabled Defines if touch is enabled or not
  18689. */
  18690. constructor(
  18691. /**
  18692. * Define if touch is enabled in the mouse input
  18693. */
  18694. touchEnabled?: boolean);
  18695. /**
  18696. * Attach the input controls to a specific dom element to get the input from.
  18697. * @param element Defines the element the controls should be listened from
  18698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18699. */
  18700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18701. /**
  18702. * Called on JS contextmenu event.
  18703. * Override this method to provide functionality.
  18704. */
  18705. protected onContextMenu(evt: PointerEvent): void;
  18706. /**
  18707. * Detach the current controls from the specified dom element.
  18708. * @param element Defines the element to stop listening the inputs from
  18709. */
  18710. detachControl(element: Nullable<HTMLElement>): void;
  18711. /**
  18712. * Gets the class name of the current intput.
  18713. * @returns the class name
  18714. */
  18715. getClassName(): string;
  18716. /**
  18717. * Get the friendly name associated with the input class.
  18718. * @returns the input friendly name
  18719. */
  18720. getSimpleName(): string;
  18721. }
  18722. }
  18723. declare module BABYLON {
  18724. /**
  18725. * Manage the touch inputs to control the movement of a free camera.
  18726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18727. */
  18728. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18729. /**
  18730. * Defines the camera the input is attached to.
  18731. */
  18732. camera: FreeCamera;
  18733. /**
  18734. * Defines the touch sensibility for rotation.
  18735. * The higher the faster.
  18736. */
  18737. touchAngularSensibility: number;
  18738. /**
  18739. * Defines the touch sensibility for move.
  18740. * The higher the faster.
  18741. */
  18742. touchMoveSensibility: number;
  18743. private _offsetX;
  18744. private _offsetY;
  18745. private _pointerPressed;
  18746. private _pointerInput;
  18747. private _observer;
  18748. private _onLostFocus;
  18749. /**
  18750. * Attach the input controls to a specific dom element to get the input from.
  18751. * @param element Defines the element the controls should be listened from
  18752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18753. */
  18754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18755. /**
  18756. * Detach the current controls from the specified dom element.
  18757. * @param element Defines the element to stop listening the inputs from
  18758. */
  18759. detachControl(element: Nullable<HTMLElement>): void;
  18760. /**
  18761. * Update the current camera state depending on the inputs that have been used this frame.
  18762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18763. */
  18764. checkInputs(): void;
  18765. /**
  18766. * Gets the class name of the current intput.
  18767. * @returns the class name
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Get the friendly name associated with the input class.
  18772. * @returns the input friendly name
  18773. */
  18774. getSimpleName(): string;
  18775. }
  18776. }
  18777. declare module BABYLON {
  18778. /**
  18779. * Default Inputs manager for the FreeCamera.
  18780. * It groups all the default supported inputs for ease of use.
  18781. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18782. */
  18783. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18784. /**
  18785. * @hidden
  18786. */
  18787. _mouseInput: Nullable<FreeCameraMouseInput>;
  18788. /**
  18789. * Instantiates a new FreeCameraInputsManager.
  18790. * @param camera Defines the camera the inputs belong to
  18791. */
  18792. constructor(camera: FreeCamera);
  18793. /**
  18794. * Add keyboard input support to the input manager.
  18795. * @returns the current input manager
  18796. */
  18797. addKeyboard(): FreeCameraInputsManager;
  18798. /**
  18799. * Add mouse input support to the input manager.
  18800. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18801. * @returns the current input manager
  18802. */
  18803. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18804. /**
  18805. * Removes the mouse input support from the manager
  18806. * @returns the current input manager
  18807. */
  18808. removeMouse(): FreeCameraInputsManager;
  18809. /**
  18810. * Add touch input support to the input manager.
  18811. * @returns the current input manager
  18812. */
  18813. addTouch(): FreeCameraInputsManager;
  18814. /**
  18815. * Remove all attached input methods from a camera
  18816. */
  18817. clear(): void;
  18818. }
  18819. }
  18820. declare module BABYLON {
  18821. /**
  18822. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18823. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18824. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18825. */
  18826. export class FreeCamera extends TargetCamera {
  18827. /**
  18828. * Define the collision ellipsoid of the camera.
  18829. * This is helpful to simulate a camera body like the player body around the camera
  18830. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18831. */
  18832. ellipsoid: Vector3;
  18833. /**
  18834. * Define an offset for the position of the ellipsoid around the camera.
  18835. * This can be helpful to determine the center of the body near the gravity center of the body
  18836. * instead of its head.
  18837. */
  18838. ellipsoidOffset: Vector3;
  18839. /**
  18840. * Enable or disable collisions of the camera with the rest of the scene objects.
  18841. */
  18842. checkCollisions: boolean;
  18843. /**
  18844. * Enable or disable gravity on the camera.
  18845. */
  18846. applyGravity: boolean;
  18847. /**
  18848. * Define the input manager associated to the camera.
  18849. */
  18850. inputs: FreeCameraInputsManager;
  18851. /**
  18852. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18853. * Higher values reduce sensitivity.
  18854. */
  18855. get angularSensibility(): number;
  18856. /**
  18857. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18858. * Higher values reduce sensitivity.
  18859. */
  18860. set angularSensibility(value: number);
  18861. /**
  18862. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18863. */
  18864. get keysUp(): number[];
  18865. set keysUp(value: number[]);
  18866. /**
  18867. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18868. */
  18869. get keysUpward(): number[];
  18870. set keysUpward(value: number[]);
  18871. /**
  18872. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18873. */
  18874. get keysDown(): number[];
  18875. set keysDown(value: number[]);
  18876. /**
  18877. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18878. */
  18879. get keysDownward(): number[];
  18880. set keysDownward(value: number[]);
  18881. /**
  18882. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18883. */
  18884. get keysLeft(): number[];
  18885. set keysLeft(value: number[]);
  18886. /**
  18887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18888. */
  18889. get keysRight(): number[];
  18890. set keysRight(value: number[]);
  18891. /**
  18892. * Event raised when the camera collide with a mesh in the scene.
  18893. */
  18894. onCollide: (collidedMesh: AbstractMesh) => void;
  18895. private _collider;
  18896. private _needMoveForGravity;
  18897. private _oldPosition;
  18898. private _diffPosition;
  18899. private _newPosition;
  18900. /** @hidden */
  18901. _localDirection: Vector3;
  18902. /** @hidden */
  18903. _transformedDirection: Vector3;
  18904. /**
  18905. * Instantiates a Free Camera.
  18906. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18907. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18908. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18909. * @param name Define the name of the camera in the scene
  18910. * @param position Define the start position of the camera in the scene
  18911. * @param scene Define the scene the camera belongs to
  18912. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18913. */
  18914. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18915. /**
  18916. * Attached controls to the current camera.
  18917. * @param element Defines the element the controls should be listened from
  18918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18919. */
  18920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18921. /**
  18922. * Detach the current controls from the camera.
  18923. * The camera will stop reacting to inputs.
  18924. * @param element Defines the element to stop listening the inputs from
  18925. */
  18926. detachControl(element: HTMLElement): void;
  18927. private _collisionMask;
  18928. /**
  18929. * Define a collision mask to limit the list of object the camera can collide with
  18930. */
  18931. get collisionMask(): number;
  18932. set collisionMask(mask: number);
  18933. /** @hidden */
  18934. _collideWithWorld(displacement: Vector3): void;
  18935. private _onCollisionPositionChange;
  18936. /** @hidden */
  18937. _checkInputs(): void;
  18938. /** @hidden */
  18939. _decideIfNeedsToMove(): boolean;
  18940. /** @hidden */
  18941. _updatePosition(): void;
  18942. /**
  18943. * Destroy the camera and release the current resources hold by it.
  18944. */
  18945. dispose(): void;
  18946. /**
  18947. * Gets the current object class name.
  18948. * @return the class name
  18949. */
  18950. getClassName(): string;
  18951. }
  18952. }
  18953. declare module BABYLON {
  18954. /**
  18955. * Represents a gamepad control stick position
  18956. */
  18957. export class StickValues {
  18958. /**
  18959. * The x component of the control stick
  18960. */
  18961. x: number;
  18962. /**
  18963. * The y component of the control stick
  18964. */
  18965. y: number;
  18966. /**
  18967. * Initializes the gamepad x and y control stick values
  18968. * @param x The x component of the gamepad control stick value
  18969. * @param y The y component of the gamepad control stick value
  18970. */
  18971. constructor(
  18972. /**
  18973. * The x component of the control stick
  18974. */
  18975. x: number,
  18976. /**
  18977. * The y component of the control stick
  18978. */
  18979. y: number);
  18980. }
  18981. /**
  18982. * An interface which manages callbacks for gamepad button changes
  18983. */
  18984. export interface GamepadButtonChanges {
  18985. /**
  18986. * Called when a gamepad has been changed
  18987. */
  18988. changed: boolean;
  18989. /**
  18990. * Called when a gamepad press event has been triggered
  18991. */
  18992. pressChanged: boolean;
  18993. /**
  18994. * Called when a touch event has been triggered
  18995. */
  18996. touchChanged: boolean;
  18997. /**
  18998. * Called when a value has changed
  18999. */
  19000. valueChanged: boolean;
  19001. }
  19002. /**
  19003. * Represents a gamepad
  19004. */
  19005. export class Gamepad {
  19006. /**
  19007. * The id of the gamepad
  19008. */
  19009. id: string;
  19010. /**
  19011. * The index of the gamepad
  19012. */
  19013. index: number;
  19014. /**
  19015. * The browser gamepad
  19016. */
  19017. browserGamepad: any;
  19018. /**
  19019. * Specifies what type of gamepad this represents
  19020. */
  19021. type: number;
  19022. private _leftStick;
  19023. private _rightStick;
  19024. /** @hidden */
  19025. _isConnected: boolean;
  19026. private _leftStickAxisX;
  19027. private _leftStickAxisY;
  19028. private _rightStickAxisX;
  19029. private _rightStickAxisY;
  19030. /**
  19031. * Triggered when the left control stick has been changed
  19032. */
  19033. private _onleftstickchanged;
  19034. /**
  19035. * Triggered when the right control stick has been changed
  19036. */
  19037. private _onrightstickchanged;
  19038. /**
  19039. * Represents a gamepad controller
  19040. */
  19041. static GAMEPAD: number;
  19042. /**
  19043. * Represents a generic controller
  19044. */
  19045. static GENERIC: number;
  19046. /**
  19047. * Represents an XBox controller
  19048. */
  19049. static XBOX: number;
  19050. /**
  19051. * Represents a pose-enabled controller
  19052. */
  19053. static POSE_ENABLED: number;
  19054. /**
  19055. * Represents an Dual Shock controller
  19056. */
  19057. static DUALSHOCK: number;
  19058. /**
  19059. * Specifies whether the left control stick should be Y-inverted
  19060. */
  19061. protected _invertLeftStickY: boolean;
  19062. /**
  19063. * Specifies if the gamepad has been connected
  19064. */
  19065. get isConnected(): boolean;
  19066. /**
  19067. * Initializes the gamepad
  19068. * @param id The id of the gamepad
  19069. * @param index The index of the gamepad
  19070. * @param browserGamepad The browser gamepad
  19071. * @param leftStickX The x component of the left joystick
  19072. * @param leftStickY The y component of the left joystick
  19073. * @param rightStickX The x component of the right joystick
  19074. * @param rightStickY The y component of the right joystick
  19075. */
  19076. constructor(
  19077. /**
  19078. * The id of the gamepad
  19079. */
  19080. id: string,
  19081. /**
  19082. * The index of the gamepad
  19083. */
  19084. index: number,
  19085. /**
  19086. * The browser gamepad
  19087. */
  19088. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19089. /**
  19090. * Callback triggered when the left joystick has changed
  19091. * @param callback
  19092. */
  19093. onleftstickchanged(callback: (values: StickValues) => void): void;
  19094. /**
  19095. * Callback triggered when the right joystick has changed
  19096. * @param callback
  19097. */
  19098. onrightstickchanged(callback: (values: StickValues) => void): void;
  19099. /**
  19100. * Gets the left joystick
  19101. */
  19102. get leftStick(): StickValues;
  19103. /**
  19104. * Sets the left joystick values
  19105. */
  19106. set leftStick(newValues: StickValues);
  19107. /**
  19108. * Gets the right joystick
  19109. */
  19110. get rightStick(): StickValues;
  19111. /**
  19112. * Sets the right joystick value
  19113. */
  19114. set rightStick(newValues: StickValues);
  19115. /**
  19116. * Updates the gamepad joystick positions
  19117. */
  19118. update(): void;
  19119. /**
  19120. * Disposes the gamepad
  19121. */
  19122. dispose(): void;
  19123. }
  19124. /**
  19125. * Represents a generic gamepad
  19126. */
  19127. export class GenericPad extends Gamepad {
  19128. private _buttons;
  19129. private _onbuttondown;
  19130. private _onbuttonup;
  19131. /**
  19132. * Observable triggered when a button has been pressed
  19133. */
  19134. onButtonDownObservable: Observable<number>;
  19135. /**
  19136. * Observable triggered when a button has been released
  19137. */
  19138. onButtonUpObservable: Observable<number>;
  19139. /**
  19140. * Callback triggered when a button has been pressed
  19141. * @param callback Called when a button has been pressed
  19142. */
  19143. onbuttondown(callback: (buttonPressed: number) => void): void;
  19144. /**
  19145. * Callback triggered when a button has been released
  19146. * @param callback Called when a button has been released
  19147. */
  19148. onbuttonup(callback: (buttonReleased: number) => void): void;
  19149. /**
  19150. * Initializes the generic gamepad
  19151. * @param id The id of the generic gamepad
  19152. * @param index The index of the generic gamepad
  19153. * @param browserGamepad The browser gamepad
  19154. */
  19155. constructor(id: string, index: number, browserGamepad: any);
  19156. private _setButtonValue;
  19157. /**
  19158. * Updates the generic gamepad
  19159. */
  19160. update(): void;
  19161. /**
  19162. * Disposes the generic gamepad
  19163. */
  19164. dispose(): void;
  19165. }
  19166. }
  19167. declare module BABYLON {
  19168. /**
  19169. * Defines the types of pose enabled controllers that are supported
  19170. */
  19171. export enum PoseEnabledControllerType {
  19172. /**
  19173. * HTC Vive
  19174. */
  19175. VIVE = 0,
  19176. /**
  19177. * Oculus Rift
  19178. */
  19179. OCULUS = 1,
  19180. /**
  19181. * Windows mixed reality
  19182. */
  19183. WINDOWS = 2,
  19184. /**
  19185. * Samsung gear VR
  19186. */
  19187. GEAR_VR = 3,
  19188. /**
  19189. * Google Daydream
  19190. */
  19191. DAYDREAM = 4,
  19192. /**
  19193. * Generic
  19194. */
  19195. GENERIC = 5
  19196. }
  19197. /**
  19198. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19199. */
  19200. export interface MutableGamepadButton {
  19201. /**
  19202. * Value of the button/trigger
  19203. */
  19204. value: number;
  19205. /**
  19206. * If the button/trigger is currently touched
  19207. */
  19208. touched: boolean;
  19209. /**
  19210. * If the button/trigger is currently pressed
  19211. */
  19212. pressed: boolean;
  19213. }
  19214. /**
  19215. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19216. * @hidden
  19217. */
  19218. export interface ExtendedGamepadButton extends GamepadButton {
  19219. /**
  19220. * If the button/trigger is currently pressed
  19221. */
  19222. readonly pressed: boolean;
  19223. /**
  19224. * If the button/trigger is currently touched
  19225. */
  19226. readonly touched: boolean;
  19227. /**
  19228. * Value of the button/trigger
  19229. */
  19230. readonly value: number;
  19231. }
  19232. /** @hidden */
  19233. export interface _GamePadFactory {
  19234. /**
  19235. * Returns whether or not the current gamepad can be created for this type of controller.
  19236. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19237. * @returns true if it can be created, otherwise false
  19238. */
  19239. canCreate(gamepadInfo: any): boolean;
  19240. /**
  19241. * Creates a new instance of the Gamepad.
  19242. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19243. * @returns the new gamepad instance
  19244. */
  19245. create(gamepadInfo: any): Gamepad;
  19246. }
  19247. /**
  19248. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19249. */
  19250. export class PoseEnabledControllerHelper {
  19251. /** @hidden */
  19252. static _ControllerFactories: _GamePadFactory[];
  19253. /** @hidden */
  19254. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19255. /**
  19256. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19257. * @param vrGamepad the gamepad to initialized
  19258. * @returns a vr controller of the type the gamepad identified as
  19259. */
  19260. static InitiateController(vrGamepad: any): Gamepad;
  19261. }
  19262. /**
  19263. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19264. */
  19265. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19266. /**
  19267. * If the controller is used in a webXR session
  19268. */
  19269. isXR: boolean;
  19270. private _deviceRoomPosition;
  19271. private _deviceRoomRotationQuaternion;
  19272. /**
  19273. * The device position in babylon space
  19274. */
  19275. devicePosition: Vector3;
  19276. /**
  19277. * The device rotation in babylon space
  19278. */
  19279. deviceRotationQuaternion: Quaternion;
  19280. /**
  19281. * The scale factor of the device in babylon space
  19282. */
  19283. deviceScaleFactor: number;
  19284. /**
  19285. * (Likely devicePosition should be used instead) The device position in its room space
  19286. */
  19287. position: Vector3;
  19288. /**
  19289. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19290. */
  19291. rotationQuaternion: Quaternion;
  19292. /**
  19293. * The type of controller (Eg. Windows mixed reality)
  19294. */
  19295. controllerType: PoseEnabledControllerType;
  19296. protected _calculatedPosition: Vector3;
  19297. private _calculatedRotation;
  19298. /**
  19299. * The raw pose from the device
  19300. */
  19301. rawPose: DevicePose;
  19302. private _trackPosition;
  19303. private _maxRotationDistFromHeadset;
  19304. private _draggedRoomRotation;
  19305. /**
  19306. * @hidden
  19307. */
  19308. _disableTrackPosition(fixedPosition: Vector3): void;
  19309. /**
  19310. * Internal, the mesh attached to the controller
  19311. * @hidden
  19312. */
  19313. _mesh: Nullable<AbstractMesh>;
  19314. private _poseControlledCamera;
  19315. private _leftHandSystemQuaternion;
  19316. /**
  19317. * Internal, matrix used to convert room space to babylon space
  19318. * @hidden
  19319. */
  19320. _deviceToWorld: Matrix;
  19321. /**
  19322. * Node to be used when casting a ray from the controller
  19323. * @hidden
  19324. */
  19325. _pointingPoseNode: Nullable<TransformNode>;
  19326. /**
  19327. * Name of the child mesh that can be used to cast a ray from the controller
  19328. */
  19329. static readonly POINTING_POSE: string;
  19330. /**
  19331. * Creates a new PoseEnabledController from a gamepad
  19332. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19333. */
  19334. constructor(browserGamepad: any);
  19335. private _workingMatrix;
  19336. /**
  19337. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19338. */
  19339. update(): void;
  19340. /**
  19341. * Updates only the pose device and mesh without doing any button event checking
  19342. */
  19343. protected _updatePoseAndMesh(): void;
  19344. /**
  19345. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19346. * @param poseData raw pose fromthe device
  19347. */
  19348. updateFromDevice(poseData: DevicePose): void;
  19349. /**
  19350. * @hidden
  19351. */
  19352. _meshAttachedObservable: Observable<AbstractMesh>;
  19353. /**
  19354. * Attaches a mesh to the controller
  19355. * @param mesh the mesh to be attached
  19356. */
  19357. attachToMesh(mesh: AbstractMesh): void;
  19358. /**
  19359. * Attaches the controllers mesh to a camera
  19360. * @param camera the camera the mesh should be attached to
  19361. */
  19362. attachToPoseControlledCamera(camera: TargetCamera): void;
  19363. /**
  19364. * Disposes of the controller
  19365. */
  19366. dispose(): void;
  19367. /**
  19368. * The mesh that is attached to the controller
  19369. */
  19370. get mesh(): Nullable<AbstractMesh>;
  19371. /**
  19372. * Gets the ray of the controller in the direction the controller is pointing
  19373. * @param length the length the resulting ray should be
  19374. * @returns a ray in the direction the controller is pointing
  19375. */
  19376. getForwardRay(length?: number): Ray;
  19377. }
  19378. }
  19379. declare module BABYLON {
  19380. /**
  19381. * Defines the WebVRController object that represents controllers tracked in 3D space
  19382. */
  19383. export abstract class WebVRController extends PoseEnabledController {
  19384. /**
  19385. * Internal, the default controller model for the controller
  19386. */
  19387. protected _defaultModel: Nullable<AbstractMesh>;
  19388. /**
  19389. * Fired when the trigger state has changed
  19390. */
  19391. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19392. /**
  19393. * Fired when the main button state has changed
  19394. */
  19395. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19396. /**
  19397. * Fired when the secondary button state has changed
  19398. */
  19399. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19400. /**
  19401. * Fired when the pad state has changed
  19402. */
  19403. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19404. /**
  19405. * Fired when controllers stick values have changed
  19406. */
  19407. onPadValuesChangedObservable: Observable<StickValues>;
  19408. /**
  19409. * Array of button availible on the controller
  19410. */
  19411. protected _buttons: Array<MutableGamepadButton>;
  19412. private _onButtonStateChange;
  19413. /**
  19414. * Fired when a controller button's state has changed
  19415. * @param callback the callback containing the button that was modified
  19416. */
  19417. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19418. /**
  19419. * X and Y axis corresponding to the controllers joystick
  19420. */
  19421. pad: StickValues;
  19422. /**
  19423. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19424. */
  19425. hand: string;
  19426. /**
  19427. * The default controller model for the controller
  19428. */
  19429. get defaultModel(): Nullable<AbstractMesh>;
  19430. /**
  19431. * Creates a new WebVRController from a gamepad
  19432. * @param vrGamepad the gamepad that the WebVRController should be created from
  19433. */
  19434. constructor(vrGamepad: any);
  19435. /**
  19436. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19437. */
  19438. update(): void;
  19439. /**
  19440. * Function to be called when a button is modified
  19441. */
  19442. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19443. /**
  19444. * Loads a mesh and attaches it to the controller
  19445. * @param scene the scene the mesh should be added to
  19446. * @param meshLoaded callback for when the mesh has been loaded
  19447. */
  19448. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19449. private _setButtonValue;
  19450. private _changes;
  19451. private _checkChanges;
  19452. /**
  19453. * Disposes of th webVRCOntroller
  19454. */
  19455. dispose(): void;
  19456. }
  19457. }
  19458. declare module BABYLON {
  19459. /**
  19460. * The HemisphericLight simulates the ambient environment light,
  19461. * so the passed direction is the light reflection direction, not the incoming direction.
  19462. */
  19463. export class HemisphericLight extends Light {
  19464. /**
  19465. * The groundColor is the light in the opposite direction to the one specified during creation.
  19466. * 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.
  19467. */
  19468. groundColor: Color3;
  19469. /**
  19470. * The light reflection direction, not the incoming direction.
  19471. */
  19472. direction: Vector3;
  19473. /**
  19474. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19475. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19476. * The HemisphericLight can't cast shadows.
  19477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19478. * @param name The friendly name of the light
  19479. * @param direction The direction of the light reflection
  19480. * @param scene The scene the light belongs to
  19481. */
  19482. constructor(name: string, direction: Vector3, scene: Scene);
  19483. protected _buildUniformLayout(): void;
  19484. /**
  19485. * Returns the string "HemisphericLight".
  19486. * @return The class name
  19487. */
  19488. getClassName(): string;
  19489. /**
  19490. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19491. * Returns the updated direction.
  19492. * @param target The target the direction should point to
  19493. * @return The computed direction
  19494. */
  19495. setDirectionToTarget(target: Vector3): Vector3;
  19496. /**
  19497. * Returns the shadow generator associated to the light.
  19498. * @returns Always null for hemispheric lights because it does not support shadows.
  19499. */
  19500. getShadowGenerator(): Nullable<IShadowGenerator>;
  19501. /**
  19502. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19503. * @param effect The effect to update
  19504. * @param lightIndex The index of the light in the effect to update
  19505. * @returns The hemispheric light
  19506. */
  19507. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19508. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19509. /**
  19510. * Computes the world matrix of the node
  19511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19512. * @param useWasUpdatedFlag defines a reserved property
  19513. * @returns the world matrix
  19514. */
  19515. computeWorldMatrix(): Matrix;
  19516. /**
  19517. * Returns the integer 3.
  19518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19519. */
  19520. getTypeID(): number;
  19521. /**
  19522. * Prepares the list of defines specific to the light type.
  19523. * @param defines the list of defines
  19524. * @param lightIndex defines the index of the light for the effect
  19525. */
  19526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19527. }
  19528. }
  19529. declare module BABYLON {
  19530. /** @hidden */
  19531. export var vrMultiviewToSingleviewPixelShader: {
  19532. name: string;
  19533. shader: string;
  19534. };
  19535. }
  19536. declare module BABYLON {
  19537. /**
  19538. * Renders to multiple views with a single draw call
  19539. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19540. */
  19541. export class MultiviewRenderTarget extends RenderTargetTexture {
  19542. /**
  19543. * Creates a multiview render target
  19544. * @param scene scene used with the render target
  19545. * @param size the size of the render target (used for each view)
  19546. */
  19547. constructor(scene: Scene, size?: number | {
  19548. width: number;
  19549. height: number;
  19550. } | {
  19551. ratio: number;
  19552. });
  19553. /**
  19554. * @hidden
  19555. * @param faceIndex the face index, if its a cube texture
  19556. */
  19557. _bindFrameBuffer(faceIndex?: number): void;
  19558. /**
  19559. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19560. * @returns the view count
  19561. */
  19562. getViewCount(): number;
  19563. }
  19564. }
  19565. declare module BABYLON {
  19566. interface Engine {
  19567. /**
  19568. * Creates a new multiview render target
  19569. * @param width defines the width of the texture
  19570. * @param height defines the height of the texture
  19571. * @returns the created multiview texture
  19572. */
  19573. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19574. /**
  19575. * Binds a multiview framebuffer to be drawn to
  19576. * @param multiviewTexture texture to bind
  19577. */
  19578. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19579. }
  19580. interface Camera {
  19581. /**
  19582. * @hidden
  19583. * 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)
  19584. */
  19585. _useMultiviewToSingleView: boolean;
  19586. /**
  19587. * @hidden
  19588. * 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)
  19589. */
  19590. _multiviewTexture: Nullable<RenderTargetTexture>;
  19591. /**
  19592. * @hidden
  19593. * ensures the multiview texture of the camera exists and has the specified width/height
  19594. * @param width height to set on the multiview texture
  19595. * @param height width to set on the multiview texture
  19596. */
  19597. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19598. }
  19599. interface Scene {
  19600. /** @hidden */
  19601. _transformMatrixR: Matrix;
  19602. /** @hidden */
  19603. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19604. /** @hidden */
  19605. _createMultiviewUbo(): void;
  19606. /** @hidden */
  19607. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19608. /** @hidden */
  19609. _renderMultiviewToSingleView(camera: Camera): void;
  19610. }
  19611. }
  19612. declare module BABYLON {
  19613. /**
  19614. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19615. * This will not be used for webXR as it supports displaying texture arrays directly
  19616. */
  19617. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19618. /**
  19619. * Initializes a VRMultiviewToSingleview
  19620. * @param name name of the post process
  19621. * @param camera camera to be applied to
  19622. * @param scaleFactor scaling factor to the size of the output texture
  19623. */
  19624. constructor(name: string, camera: Camera, scaleFactor: number);
  19625. }
  19626. }
  19627. declare module BABYLON {
  19628. /**
  19629. * Interface used to define additional presentation attributes
  19630. */
  19631. export interface IVRPresentationAttributes {
  19632. /**
  19633. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19634. */
  19635. highRefreshRate: boolean;
  19636. /**
  19637. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19638. */
  19639. foveationLevel: number;
  19640. }
  19641. interface Engine {
  19642. /** @hidden */
  19643. _vrDisplay: any;
  19644. /** @hidden */
  19645. _vrSupported: boolean;
  19646. /** @hidden */
  19647. _oldSize: Size;
  19648. /** @hidden */
  19649. _oldHardwareScaleFactor: number;
  19650. /** @hidden */
  19651. _vrExclusivePointerMode: boolean;
  19652. /** @hidden */
  19653. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19654. /** @hidden */
  19655. _onVRDisplayPointerRestricted: () => void;
  19656. /** @hidden */
  19657. _onVRDisplayPointerUnrestricted: () => void;
  19658. /** @hidden */
  19659. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19660. /** @hidden */
  19661. _onVrDisplayDisconnect: Nullable<() => void>;
  19662. /** @hidden */
  19663. _onVrDisplayPresentChange: Nullable<() => void>;
  19664. /**
  19665. * Observable signaled when VR display mode changes
  19666. */
  19667. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19668. /**
  19669. * Observable signaled when VR request present is complete
  19670. */
  19671. onVRRequestPresentComplete: Observable<boolean>;
  19672. /**
  19673. * Observable signaled when VR request present starts
  19674. */
  19675. onVRRequestPresentStart: Observable<Engine>;
  19676. /**
  19677. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19678. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19679. */
  19680. isInVRExclusivePointerMode: boolean;
  19681. /**
  19682. * Gets a boolean indicating if a webVR device was detected
  19683. * @returns true if a webVR device was detected
  19684. */
  19685. isVRDevicePresent(): boolean;
  19686. /**
  19687. * Gets the current webVR device
  19688. * @returns the current webVR device (or null)
  19689. */
  19690. getVRDevice(): any;
  19691. /**
  19692. * Initializes a webVR display and starts listening to display change events
  19693. * The onVRDisplayChangedObservable will be notified upon these changes
  19694. * @returns A promise containing a VRDisplay and if vr is supported
  19695. */
  19696. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19697. /** @hidden */
  19698. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19699. /**
  19700. * Gets or sets the presentation attributes used to configure VR rendering
  19701. */
  19702. vrPresentationAttributes?: IVRPresentationAttributes;
  19703. /**
  19704. * Call this function to switch to webVR mode
  19705. * Will do nothing if webVR is not supported or if there is no webVR device
  19706. * @param options the webvr options provided to the camera. mainly used for multiview
  19707. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19708. */
  19709. enableVR(options: WebVROptions): void;
  19710. /** @hidden */
  19711. _onVRFullScreenTriggered(): void;
  19712. }
  19713. }
  19714. declare module BABYLON {
  19715. /**
  19716. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19717. * IMPORTANT!! The data is right-hand data.
  19718. * @export
  19719. * @interface DevicePose
  19720. */
  19721. export interface DevicePose {
  19722. /**
  19723. * The position of the device, values in array are [x,y,z].
  19724. */
  19725. readonly position: Nullable<Float32Array>;
  19726. /**
  19727. * The linearVelocity of the device, values in array are [x,y,z].
  19728. */
  19729. readonly linearVelocity: Nullable<Float32Array>;
  19730. /**
  19731. * The linearAcceleration of the device, values in array are [x,y,z].
  19732. */
  19733. readonly linearAcceleration: Nullable<Float32Array>;
  19734. /**
  19735. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19736. */
  19737. readonly orientation: Nullable<Float32Array>;
  19738. /**
  19739. * The angularVelocity of the device, values in array are [x,y,z].
  19740. */
  19741. readonly angularVelocity: Nullable<Float32Array>;
  19742. /**
  19743. * The angularAcceleration of the device, values in array are [x,y,z].
  19744. */
  19745. readonly angularAcceleration: Nullable<Float32Array>;
  19746. }
  19747. /**
  19748. * Interface representing a pose controlled object in Babylon.
  19749. * A pose controlled object has both regular pose values as well as pose values
  19750. * from an external device such as a VR head mounted display
  19751. */
  19752. export interface PoseControlled {
  19753. /**
  19754. * The position of the object in babylon space.
  19755. */
  19756. position: Vector3;
  19757. /**
  19758. * The rotation quaternion of the object in babylon space.
  19759. */
  19760. rotationQuaternion: Quaternion;
  19761. /**
  19762. * The position of the device in babylon space.
  19763. */
  19764. devicePosition?: Vector3;
  19765. /**
  19766. * The rotation quaternion of the device in babylon space.
  19767. */
  19768. deviceRotationQuaternion: Quaternion;
  19769. /**
  19770. * The raw pose coming from the device.
  19771. */
  19772. rawPose: Nullable<DevicePose>;
  19773. /**
  19774. * The scale of the device to be used when translating from device space to babylon space.
  19775. */
  19776. deviceScaleFactor: number;
  19777. /**
  19778. * Updates the poseControlled values based on the input device pose.
  19779. * @param poseData the pose data to update the object with
  19780. */
  19781. updateFromDevice(poseData: DevicePose): void;
  19782. }
  19783. /**
  19784. * Set of options to customize the webVRCamera
  19785. */
  19786. export interface WebVROptions {
  19787. /**
  19788. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19789. */
  19790. trackPosition?: boolean;
  19791. /**
  19792. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19793. */
  19794. positionScale?: number;
  19795. /**
  19796. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19797. */
  19798. displayName?: string;
  19799. /**
  19800. * Should the native controller meshes be initialized. (default: true)
  19801. */
  19802. controllerMeshes?: boolean;
  19803. /**
  19804. * Creating a default HemiLight only on controllers. (default: true)
  19805. */
  19806. defaultLightingOnControllers?: boolean;
  19807. /**
  19808. * If you don't want to use the default VR button of the helper. (default: false)
  19809. */
  19810. useCustomVRButton?: boolean;
  19811. /**
  19812. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19813. */
  19814. customVRButton?: HTMLButtonElement;
  19815. /**
  19816. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19817. */
  19818. rayLength?: number;
  19819. /**
  19820. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19821. */
  19822. defaultHeight?: number;
  19823. /**
  19824. * If multiview should be used if availible (default: false)
  19825. */
  19826. useMultiview?: boolean;
  19827. }
  19828. /**
  19829. * This represents a WebVR camera.
  19830. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19831. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19832. */
  19833. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19834. private webVROptions;
  19835. /**
  19836. * @hidden
  19837. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19838. */
  19839. _vrDevice: any;
  19840. /**
  19841. * The rawPose of the vrDevice.
  19842. */
  19843. rawPose: Nullable<DevicePose>;
  19844. private _onVREnabled;
  19845. private _specsVersion;
  19846. private _attached;
  19847. private _frameData;
  19848. protected _descendants: Array<Node>;
  19849. private _deviceRoomPosition;
  19850. /** @hidden */
  19851. _deviceRoomRotationQuaternion: Quaternion;
  19852. private _standingMatrix;
  19853. /**
  19854. * Represents device position in babylon space.
  19855. */
  19856. devicePosition: Vector3;
  19857. /**
  19858. * Represents device rotation in babylon space.
  19859. */
  19860. deviceRotationQuaternion: Quaternion;
  19861. /**
  19862. * The scale of the device to be used when translating from device space to babylon space.
  19863. */
  19864. deviceScaleFactor: number;
  19865. private _deviceToWorld;
  19866. private _worldToDevice;
  19867. /**
  19868. * References to the webVR controllers for the vrDevice.
  19869. */
  19870. controllers: Array<WebVRController>;
  19871. /**
  19872. * Emits an event when a controller is attached.
  19873. */
  19874. onControllersAttachedObservable: Observable<WebVRController[]>;
  19875. /**
  19876. * Emits an event when a controller's mesh has been loaded;
  19877. */
  19878. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19879. /**
  19880. * Emits an event when the HMD's pose has been updated.
  19881. */
  19882. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19883. private _poseSet;
  19884. /**
  19885. * If the rig cameras be used as parent instead of this camera.
  19886. */
  19887. rigParenting: boolean;
  19888. private _lightOnControllers;
  19889. private _defaultHeight?;
  19890. /**
  19891. * Instantiates a WebVRFreeCamera.
  19892. * @param name The name of the WebVRFreeCamera
  19893. * @param position The starting anchor position for the camera
  19894. * @param scene The scene the camera belongs to
  19895. * @param webVROptions a set of customizable options for the webVRCamera
  19896. */
  19897. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19898. /**
  19899. * Gets the device distance from the ground in meters.
  19900. * @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.
  19901. */
  19902. deviceDistanceToRoomGround(): number;
  19903. /**
  19904. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19905. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19906. */
  19907. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19908. /**
  19909. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19910. * @returns A promise with a boolean set to if the standing matrix is supported.
  19911. */
  19912. useStandingMatrixAsync(): Promise<boolean>;
  19913. /**
  19914. * Disposes the camera
  19915. */
  19916. dispose(): void;
  19917. /**
  19918. * Gets a vrController by name.
  19919. * @param name The name of the controller to retreive
  19920. * @returns the controller matching the name specified or null if not found
  19921. */
  19922. getControllerByName(name: string): Nullable<WebVRController>;
  19923. private _leftController;
  19924. /**
  19925. * The controller corresponding to the users left hand.
  19926. */
  19927. get leftController(): Nullable<WebVRController>;
  19928. private _rightController;
  19929. /**
  19930. * The controller corresponding to the users right hand.
  19931. */
  19932. get rightController(): Nullable<WebVRController>;
  19933. /**
  19934. * Casts a ray forward from the vrCamera's gaze.
  19935. * @param length Length of the ray (default: 100)
  19936. * @returns the ray corresponding to the gaze
  19937. */
  19938. getForwardRay(length?: number): Ray;
  19939. /**
  19940. * @hidden
  19941. * Updates the camera based on device's frame data
  19942. */
  19943. _checkInputs(): void;
  19944. /**
  19945. * Updates the poseControlled values based on the input device pose.
  19946. * @param poseData Pose coming from the device
  19947. */
  19948. updateFromDevice(poseData: DevicePose): void;
  19949. private _htmlElementAttached;
  19950. private _detachIfAttached;
  19951. /**
  19952. * WebVR's attach control will start broadcasting frames to the device.
  19953. * Note that in certain browsers (chrome for example) this function must be called
  19954. * within a user-interaction callback. Example:
  19955. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19956. *
  19957. * @param element html element to attach the vrDevice to
  19958. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19959. */
  19960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19961. /**
  19962. * Detaches the camera from the html element and disables VR
  19963. *
  19964. * @param element html element to detach from
  19965. */
  19966. detachControl(element: HTMLElement): void;
  19967. /**
  19968. * @returns the name of this class
  19969. */
  19970. getClassName(): string;
  19971. /**
  19972. * Calls resetPose on the vrDisplay
  19973. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19974. */
  19975. resetToCurrentRotation(): void;
  19976. /**
  19977. * @hidden
  19978. * Updates the rig cameras (left and right eye)
  19979. */
  19980. _updateRigCameras(): void;
  19981. private _workingVector;
  19982. private _oneVector;
  19983. private _workingMatrix;
  19984. private updateCacheCalled;
  19985. private _correctPositionIfNotTrackPosition;
  19986. /**
  19987. * @hidden
  19988. * Updates the cached values of the camera
  19989. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19990. */
  19991. _updateCache(ignoreParentClass?: boolean): void;
  19992. /**
  19993. * @hidden
  19994. * Get current device position in babylon world
  19995. */
  19996. _computeDevicePosition(): void;
  19997. /**
  19998. * Updates the current device position and rotation in the babylon world
  19999. */
  20000. update(): void;
  20001. /**
  20002. * @hidden
  20003. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20004. * @returns an identity matrix
  20005. */
  20006. _getViewMatrix(): Matrix;
  20007. private _tmpMatrix;
  20008. /**
  20009. * This function is called by the two RIG cameras.
  20010. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20011. * @hidden
  20012. */
  20013. _getWebVRViewMatrix(): Matrix;
  20014. /** @hidden */
  20015. _getWebVRProjectionMatrix(): Matrix;
  20016. private _onGamepadConnectedObserver;
  20017. private _onGamepadDisconnectedObserver;
  20018. private _updateCacheWhenTrackingDisabledObserver;
  20019. /**
  20020. * Initializes the controllers and their meshes
  20021. */
  20022. initControllers(): void;
  20023. }
  20024. }
  20025. declare module BABYLON {
  20026. /**
  20027. * "Static Class" containing the most commonly used helper while dealing with material for
  20028. * rendering purpose.
  20029. *
  20030. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20031. *
  20032. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20033. */
  20034. export class MaterialHelper {
  20035. /**
  20036. * Bind the current view position to an effect.
  20037. * @param effect The effect to be bound
  20038. * @param scene The scene the eyes position is used from
  20039. * @param variableName name of the shader variable that will hold the eye position
  20040. */
  20041. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20042. /**
  20043. * Helps preparing the defines values about the UVs in used in the effect.
  20044. * UVs are shared as much as we can accross channels in the shaders.
  20045. * @param texture The texture we are preparing the UVs for
  20046. * @param defines The defines to update
  20047. * @param key The channel key "diffuse", "specular"... used in the shader
  20048. */
  20049. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20050. /**
  20051. * Binds a texture matrix value to its corrsponding uniform
  20052. * @param texture The texture to bind the matrix for
  20053. * @param uniformBuffer The uniform buffer receivin the data
  20054. * @param key The channel key "diffuse", "specular"... used in the shader
  20055. */
  20056. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20057. /**
  20058. * Gets the current status of the fog (should it be enabled?)
  20059. * @param mesh defines the mesh to evaluate for fog support
  20060. * @param scene defines the hosting scene
  20061. * @returns true if fog must be enabled
  20062. */
  20063. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20064. /**
  20065. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20066. * @param mesh defines the current mesh
  20067. * @param scene defines the current scene
  20068. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20069. * @param pointsCloud defines if point cloud rendering has to be turned on
  20070. * @param fogEnabled defines if fog has to be turned on
  20071. * @param alphaTest defines if alpha testing has to be turned on
  20072. * @param defines defines the current list of defines
  20073. */
  20074. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20075. /**
  20076. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20077. * @param scene defines the current scene
  20078. * @param engine defines the current engine
  20079. * @param defines specifies the list of active defines
  20080. * @param useInstances defines if instances have to be turned on
  20081. * @param useClipPlane defines if clip plane have to be turned on
  20082. * @param useInstances defines if instances have to be turned on
  20083. * @param useThinInstances defines if thin instances have to be turned on
  20084. */
  20085. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20086. /**
  20087. * Prepares the defines for bones
  20088. * @param mesh The mesh containing the geometry data we will draw
  20089. * @param defines The defines to update
  20090. */
  20091. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20092. /**
  20093. * Prepares the defines for morph targets
  20094. * @param mesh The mesh containing the geometry data we will draw
  20095. * @param defines The defines to update
  20096. */
  20097. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20098. /**
  20099. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20100. * @param mesh The mesh containing the geometry data we will draw
  20101. * @param defines The defines to update
  20102. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20103. * @param useBones Precise whether bones should be used or not (override mesh info)
  20104. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20105. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20106. * @returns false if defines are considered not dirty and have not been checked
  20107. */
  20108. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20109. /**
  20110. * Prepares the defines related to multiview
  20111. * @param scene The scene we are intending to draw
  20112. * @param defines The defines to update
  20113. */
  20114. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20115. /**
  20116. * Prepares the defines related to the prepass
  20117. * @param scene The scene we are intending to draw
  20118. * @param defines The defines to update
  20119. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20120. */
  20121. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20122. /**
  20123. * Prepares the defines related to the light information passed in parameter
  20124. * @param scene The scene we are intending to draw
  20125. * @param mesh The mesh the effect is compiling for
  20126. * @param light The light the effect is compiling for
  20127. * @param lightIndex The index of the light
  20128. * @param defines The defines to update
  20129. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20130. * @param state Defines the current state regarding what is needed (normals, etc...)
  20131. */
  20132. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20133. needNormals: boolean;
  20134. needRebuild: boolean;
  20135. shadowEnabled: boolean;
  20136. specularEnabled: boolean;
  20137. lightmapMode: boolean;
  20138. }): void;
  20139. /**
  20140. * Prepares the defines related to the light information passed in parameter
  20141. * @param scene The scene we are intending to draw
  20142. * @param mesh The mesh the effect is compiling for
  20143. * @param defines The defines to update
  20144. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20145. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20146. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20147. * @returns true if normals will be required for the rest of the effect
  20148. */
  20149. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20150. /**
  20151. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20152. * @param lightIndex defines the light index
  20153. * @param uniformsList The uniform list
  20154. * @param samplersList The sampler list
  20155. * @param projectedLightTexture defines if projected texture must be used
  20156. * @param uniformBuffersList defines an optional list of uniform buffers
  20157. */
  20158. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20159. /**
  20160. * Prepares the uniforms and samplers list to be used in the effect
  20161. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20162. * @param samplersList The sampler list
  20163. * @param defines The defines helping in the list generation
  20164. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20165. */
  20166. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20167. /**
  20168. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20169. * @param defines The defines to update while falling back
  20170. * @param fallbacks The authorized effect fallbacks
  20171. * @param maxSimultaneousLights The maximum number of lights allowed
  20172. * @param rank the current rank of the Effect
  20173. * @returns The newly affected rank
  20174. */
  20175. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20176. private static _TmpMorphInfluencers;
  20177. /**
  20178. * Prepares the list of attributes required for morph targets according to the effect defines.
  20179. * @param attribs The current list of supported attribs
  20180. * @param mesh The mesh to prepare the morph targets attributes for
  20181. * @param influencers The number of influencers
  20182. */
  20183. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20184. /**
  20185. * Prepares the list of attributes required for morph targets according to the effect defines.
  20186. * @param attribs The current list of supported attribs
  20187. * @param mesh The mesh to prepare the morph targets attributes for
  20188. * @param defines The current Defines of the effect
  20189. */
  20190. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20191. /**
  20192. * Prepares the list of attributes required for bones according to the effect defines.
  20193. * @param attribs The current list of supported attribs
  20194. * @param mesh The mesh to prepare the bones attributes for
  20195. * @param defines The current Defines of the effect
  20196. * @param fallbacks The current efffect fallback strategy
  20197. */
  20198. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20199. /**
  20200. * Check and prepare the list of attributes required for instances according to the effect defines.
  20201. * @param attribs The current list of supported attribs
  20202. * @param defines The current MaterialDefines of the effect
  20203. */
  20204. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20205. /**
  20206. * Add the list of attributes required for instances to the attribs array.
  20207. * @param attribs The current list of supported attribs
  20208. */
  20209. static PushAttributesForInstances(attribs: string[]): void;
  20210. /**
  20211. * Binds the light information to the effect.
  20212. * @param light The light containing the generator
  20213. * @param effect The effect we are binding the data to
  20214. * @param lightIndex The light index in the effect used to render
  20215. */
  20216. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20217. /**
  20218. * Binds the lights information from the scene to the effect for the given mesh.
  20219. * @param light Light to bind
  20220. * @param lightIndex Light index
  20221. * @param scene The scene where the light belongs to
  20222. * @param effect The effect we are binding the data to
  20223. * @param useSpecular Defines if specular is supported
  20224. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20225. */
  20226. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20227. /**
  20228. * Binds the lights information from the scene to the effect for the given mesh.
  20229. * @param scene The scene the lights belongs to
  20230. * @param mesh The mesh we are binding the information to render
  20231. * @param effect The effect we are binding the data to
  20232. * @param defines The generated defines for the effect
  20233. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20234. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20235. */
  20236. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20237. private static _tempFogColor;
  20238. /**
  20239. * Binds the fog information from the scene to the effect for the given mesh.
  20240. * @param scene The scene the lights belongs to
  20241. * @param mesh The mesh we are binding the information to render
  20242. * @param effect The effect we are binding the data to
  20243. * @param linearSpace Defines if the fog effect is applied in linear space
  20244. */
  20245. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20246. /**
  20247. * Binds the bones information from the mesh to the effect.
  20248. * @param mesh The mesh we are binding the information to render
  20249. * @param effect The effect we are binding the data to
  20250. */
  20251. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20252. /**
  20253. * Binds the morph targets information from the mesh to the effect.
  20254. * @param abstractMesh The mesh we are binding the information to render
  20255. * @param effect The effect we are binding the data to
  20256. */
  20257. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20258. /**
  20259. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20260. * @param defines The generated defines used in the effect
  20261. * @param effect The effect we are binding the data to
  20262. * @param scene The scene we are willing to render with logarithmic scale for
  20263. */
  20264. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20265. /**
  20266. * Binds the clip plane information from the scene to the effect.
  20267. * @param scene The scene the clip plane information are extracted from
  20268. * @param effect The effect we are binding the data to
  20269. */
  20270. static BindClipPlane(effect: Effect, scene: Scene): void;
  20271. }
  20272. }
  20273. declare module BABYLON {
  20274. /**
  20275. * Block used to expose an input value
  20276. */
  20277. export class InputBlock extends NodeMaterialBlock {
  20278. private _mode;
  20279. private _associatedVariableName;
  20280. private _storedValue;
  20281. private _valueCallback;
  20282. private _type;
  20283. private _animationType;
  20284. /** Gets or set a value used to limit the range of float values */
  20285. min: number;
  20286. /** Gets or set a value used to limit the range of float values */
  20287. max: number;
  20288. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20289. isBoolean: boolean;
  20290. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20291. matrixMode: number;
  20292. /** @hidden */
  20293. _systemValue: Nullable<NodeMaterialSystemValues>;
  20294. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20295. visibleInInspector: boolean;
  20296. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20297. isConstant: boolean;
  20298. /** Gets or sets the group to use to display this block in the Inspector */
  20299. groupInInspector: string;
  20300. /** Gets an observable raised when the value is changed */
  20301. onValueChangedObservable: Observable<InputBlock>;
  20302. /**
  20303. * Gets or sets the connection point type (default is float)
  20304. */
  20305. get type(): NodeMaterialBlockConnectionPointTypes;
  20306. /**
  20307. * Creates a new InputBlock
  20308. * @param name defines the block name
  20309. * @param target defines the target of that block (Vertex by default)
  20310. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20311. */
  20312. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20313. /**
  20314. * Validates if a name is a reserve word.
  20315. * @param newName the new name to be given to the node.
  20316. * @returns false if the name is a reserve word, else true.
  20317. */
  20318. validateBlockName(newName: string): boolean;
  20319. /**
  20320. * Gets the output component
  20321. */
  20322. get output(): NodeMaterialConnectionPoint;
  20323. /**
  20324. * Set the source of this connection point to a vertex attribute
  20325. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20326. * @returns the current connection point
  20327. */
  20328. setAsAttribute(attributeName?: string): InputBlock;
  20329. /**
  20330. * Set the source of this connection point to a system value
  20331. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20332. * @returns the current connection point
  20333. */
  20334. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20335. /**
  20336. * Gets or sets the value of that point.
  20337. * Please note that this value will be ignored if valueCallback is defined
  20338. */
  20339. get value(): any;
  20340. set value(value: any);
  20341. /**
  20342. * Gets or sets a callback used to get the value of that point.
  20343. * Please note that setting this value will force the connection point to ignore the value property
  20344. */
  20345. get valueCallback(): () => any;
  20346. set valueCallback(value: () => any);
  20347. /**
  20348. * Gets or sets the associated variable name in the shader
  20349. */
  20350. get associatedVariableName(): string;
  20351. set associatedVariableName(value: string);
  20352. /** Gets or sets the type of animation applied to the input */
  20353. get animationType(): AnimatedInputBlockTypes;
  20354. set animationType(value: AnimatedInputBlockTypes);
  20355. /**
  20356. * Gets a boolean indicating that this connection point not defined yet
  20357. */
  20358. get isUndefined(): boolean;
  20359. /**
  20360. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20361. * In this case the connection point name must be the name of the uniform to use.
  20362. * Can only be set on inputs
  20363. */
  20364. get isUniform(): boolean;
  20365. set isUniform(value: boolean);
  20366. /**
  20367. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20368. * In this case the connection point name must be the name of the attribute to use
  20369. * Can only be set on inputs
  20370. */
  20371. get isAttribute(): boolean;
  20372. set isAttribute(value: boolean);
  20373. /**
  20374. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20375. * Can only be set on exit points
  20376. */
  20377. get isVarying(): boolean;
  20378. set isVarying(value: boolean);
  20379. /**
  20380. * Gets a boolean indicating that the current connection point is a system value
  20381. */
  20382. get isSystemValue(): boolean;
  20383. /**
  20384. * Gets or sets the current well known value or null if not defined as a system value
  20385. */
  20386. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20387. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20388. /**
  20389. * Gets the current class name
  20390. * @returns the class name
  20391. */
  20392. getClassName(): string;
  20393. /**
  20394. * Animate the input if animationType !== None
  20395. * @param scene defines the rendering scene
  20396. */
  20397. animate(scene: Scene): void;
  20398. private _emitDefine;
  20399. initialize(state: NodeMaterialBuildState): void;
  20400. /**
  20401. * Set the input block to its default value (based on its type)
  20402. */
  20403. setDefaultValue(): void;
  20404. private _emitConstant;
  20405. /** @hidden */
  20406. get _noContextSwitch(): boolean;
  20407. private _emit;
  20408. /** @hidden */
  20409. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20410. /** @hidden */
  20411. _transmit(effect: Effect, scene: Scene): void;
  20412. protected _buildBlock(state: NodeMaterialBuildState): void;
  20413. protected _dumpPropertiesCode(): string;
  20414. dispose(): void;
  20415. serialize(): any;
  20416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20417. }
  20418. }
  20419. declare module BABYLON {
  20420. /**
  20421. * Enum used to define the compatibility state between two connection points
  20422. */
  20423. export enum NodeMaterialConnectionPointCompatibilityStates {
  20424. /** Points are compatibles */
  20425. Compatible = 0,
  20426. /** Points are incompatible because of their types */
  20427. TypeIncompatible = 1,
  20428. /** Points are incompatible because of their targets (vertex vs fragment) */
  20429. TargetIncompatible = 2
  20430. }
  20431. /**
  20432. * Defines the direction of a connection point
  20433. */
  20434. export enum NodeMaterialConnectionPointDirection {
  20435. /** Input */
  20436. Input = 0,
  20437. /** Output */
  20438. Output = 1
  20439. }
  20440. /**
  20441. * Defines a connection point for a block
  20442. */
  20443. export class NodeMaterialConnectionPoint {
  20444. /** @hidden */
  20445. _ownerBlock: NodeMaterialBlock;
  20446. /** @hidden */
  20447. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20448. private _endpoints;
  20449. private _associatedVariableName;
  20450. private _direction;
  20451. /** @hidden */
  20452. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20453. /** @hidden */
  20454. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20455. private _type;
  20456. /** @hidden */
  20457. _enforceAssociatedVariableName: boolean;
  20458. /** Gets the direction of the point */
  20459. get direction(): NodeMaterialConnectionPointDirection;
  20460. /** Indicates that this connection point needs dual validation before being connected to another point */
  20461. needDualDirectionValidation: boolean;
  20462. /**
  20463. * Gets or sets the additional types supported by this connection point
  20464. */
  20465. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20466. /**
  20467. * Gets or sets the additional types excluded by this connection point
  20468. */
  20469. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20470. /**
  20471. * Observable triggered when this point is connected
  20472. */
  20473. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20474. /**
  20475. * Gets or sets the associated variable name in the shader
  20476. */
  20477. get associatedVariableName(): string;
  20478. set associatedVariableName(value: string);
  20479. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20480. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20481. /**
  20482. * Gets or sets the connection point type (default is float)
  20483. */
  20484. get type(): NodeMaterialBlockConnectionPointTypes;
  20485. set type(value: NodeMaterialBlockConnectionPointTypes);
  20486. /**
  20487. * Gets or sets the connection point name
  20488. */
  20489. name: string;
  20490. /**
  20491. * Gets or sets the connection point name
  20492. */
  20493. displayName: string;
  20494. /**
  20495. * Gets or sets a boolean indicating that this connection point can be omitted
  20496. */
  20497. isOptional: boolean;
  20498. /**
  20499. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20500. */
  20501. isExposedOnFrame: boolean;
  20502. /**
  20503. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20504. */
  20505. define: string;
  20506. /** @hidden */
  20507. _prioritizeVertex: boolean;
  20508. private _target;
  20509. /** Gets or sets the target of that connection point */
  20510. get target(): NodeMaterialBlockTargets;
  20511. set target(value: NodeMaterialBlockTargets);
  20512. /**
  20513. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20514. */
  20515. get isConnected(): boolean;
  20516. /**
  20517. * Gets a boolean indicating that the current point is connected to an input block
  20518. */
  20519. get isConnectedToInputBlock(): boolean;
  20520. /**
  20521. * Gets a the connected input block (if any)
  20522. */
  20523. get connectInputBlock(): Nullable<InputBlock>;
  20524. /** Get the other side of the connection (if any) */
  20525. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20526. /** Get the block that owns this connection point */
  20527. get ownerBlock(): NodeMaterialBlock;
  20528. /** Get the block connected on the other side of this connection (if any) */
  20529. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20530. /** Get the block connected on the endpoints of this connection (if any) */
  20531. get connectedBlocks(): Array<NodeMaterialBlock>;
  20532. /** Gets the list of connected endpoints */
  20533. get endpoints(): NodeMaterialConnectionPoint[];
  20534. /** Gets a boolean indicating if that output point is connected to at least one input */
  20535. get hasEndpoints(): boolean;
  20536. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20537. get isConnectedInVertexShader(): boolean;
  20538. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20539. get isConnectedInFragmentShader(): boolean;
  20540. /**
  20541. * Creates a block suitable to be used as an input for this input point.
  20542. * If null is returned, a block based on the point type will be created.
  20543. * @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
  20544. */
  20545. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20546. /**
  20547. * Creates a new connection point
  20548. * @param name defines the connection point name
  20549. * @param ownerBlock defines the block hosting this connection point
  20550. * @param direction defines the direction of the connection point
  20551. */
  20552. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20553. /**
  20554. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20555. * @returns the class name
  20556. */
  20557. getClassName(): string;
  20558. /**
  20559. * Gets a boolean indicating if the current point can be connected to another point
  20560. * @param connectionPoint defines the other connection point
  20561. * @returns a boolean
  20562. */
  20563. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20564. /**
  20565. * Gets a number indicating if the current point can be connected to another point
  20566. * @param connectionPoint defines the other connection point
  20567. * @returns a number defining the compatibility state
  20568. */
  20569. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20570. /**
  20571. * Connect this point to another connection point
  20572. * @param connectionPoint defines the other connection point
  20573. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20574. * @returns the current connection point
  20575. */
  20576. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20577. /**
  20578. * Disconnect this point from one of his endpoint
  20579. * @param endpoint defines the other connection point
  20580. * @returns the current connection point
  20581. */
  20582. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20583. /**
  20584. * Serializes this point in a JSON representation
  20585. * @param isInput defines if the connection point is an input (default is true)
  20586. * @returns the serialized point object
  20587. */
  20588. serialize(isInput?: boolean): any;
  20589. /**
  20590. * Release resources
  20591. */
  20592. dispose(): void;
  20593. }
  20594. }
  20595. declare module BABYLON {
  20596. /**
  20597. * Enum used to define the material modes
  20598. */
  20599. export enum NodeMaterialModes {
  20600. /** Regular material */
  20601. Material = 0,
  20602. /** For post process */
  20603. PostProcess = 1,
  20604. /** For particle system */
  20605. Particle = 2
  20606. }
  20607. }
  20608. declare module BABYLON {
  20609. /**
  20610. * Block used to read a texture from a sampler
  20611. */
  20612. export class TextureBlock extends NodeMaterialBlock {
  20613. private _defineName;
  20614. private _linearDefineName;
  20615. private _gammaDefineName;
  20616. private _tempTextureRead;
  20617. private _samplerName;
  20618. private _transformedUVName;
  20619. private _textureTransformName;
  20620. private _textureInfoName;
  20621. private _mainUVName;
  20622. private _mainUVDefineName;
  20623. private _fragmentOnly;
  20624. /**
  20625. * Gets or sets the texture associated with the node
  20626. */
  20627. texture: Nullable<Texture>;
  20628. /**
  20629. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20630. */
  20631. convertToGammaSpace: boolean;
  20632. /**
  20633. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20634. */
  20635. convertToLinearSpace: boolean;
  20636. /**
  20637. * Create a new TextureBlock
  20638. * @param name defines the block name
  20639. */
  20640. constructor(name: string, fragmentOnly?: boolean);
  20641. /**
  20642. * Gets the current class name
  20643. * @returns the class name
  20644. */
  20645. getClassName(): string;
  20646. /**
  20647. * Gets the uv input component
  20648. */
  20649. get uv(): NodeMaterialConnectionPoint;
  20650. /**
  20651. * Gets the rgba output component
  20652. */
  20653. get rgba(): NodeMaterialConnectionPoint;
  20654. /**
  20655. * Gets the rgb output component
  20656. */
  20657. get rgb(): NodeMaterialConnectionPoint;
  20658. /**
  20659. * Gets the r output component
  20660. */
  20661. get r(): NodeMaterialConnectionPoint;
  20662. /**
  20663. * Gets the g output component
  20664. */
  20665. get g(): NodeMaterialConnectionPoint;
  20666. /**
  20667. * Gets the b output component
  20668. */
  20669. get b(): NodeMaterialConnectionPoint;
  20670. /**
  20671. * Gets the a output component
  20672. */
  20673. get a(): NodeMaterialConnectionPoint;
  20674. get target(): NodeMaterialBlockTargets;
  20675. autoConfigure(material: NodeMaterial): void;
  20676. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20678. isReady(): boolean;
  20679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20680. private get _isMixed();
  20681. private _injectVertexCode;
  20682. private _writeTextureRead;
  20683. private _writeOutput;
  20684. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20685. protected _dumpPropertiesCode(): string;
  20686. serialize(): any;
  20687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20688. }
  20689. }
  20690. declare module BABYLON {
  20691. /** @hidden */
  20692. export var reflectionFunction: {
  20693. name: string;
  20694. shader: string;
  20695. };
  20696. }
  20697. declare module BABYLON {
  20698. /**
  20699. * Base block used to read a reflection texture from a sampler
  20700. */
  20701. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20702. /** @hidden */
  20703. _define3DName: string;
  20704. /** @hidden */
  20705. _defineCubicName: string;
  20706. /** @hidden */
  20707. _defineExplicitName: string;
  20708. /** @hidden */
  20709. _defineProjectionName: string;
  20710. /** @hidden */
  20711. _defineLocalCubicName: string;
  20712. /** @hidden */
  20713. _defineSphericalName: string;
  20714. /** @hidden */
  20715. _definePlanarName: string;
  20716. /** @hidden */
  20717. _defineEquirectangularName: string;
  20718. /** @hidden */
  20719. _defineMirroredEquirectangularFixedName: string;
  20720. /** @hidden */
  20721. _defineEquirectangularFixedName: string;
  20722. /** @hidden */
  20723. _defineSkyboxName: string;
  20724. /** @hidden */
  20725. _defineOppositeZ: string;
  20726. /** @hidden */
  20727. _cubeSamplerName: string;
  20728. /** @hidden */
  20729. _2DSamplerName: string;
  20730. protected _positionUVWName: string;
  20731. protected _directionWName: string;
  20732. protected _reflectionVectorName: string;
  20733. /** @hidden */
  20734. _reflectionCoordsName: string;
  20735. /** @hidden */
  20736. _reflectionMatrixName: string;
  20737. protected _reflectionColorName: string;
  20738. /**
  20739. * Gets or sets the texture associated with the node
  20740. */
  20741. texture: Nullable<BaseTexture>;
  20742. /**
  20743. * Create a new ReflectionTextureBaseBlock
  20744. * @param name defines the block name
  20745. */
  20746. constructor(name: string);
  20747. /**
  20748. * Gets the current class name
  20749. * @returns the class name
  20750. */
  20751. getClassName(): string;
  20752. /**
  20753. * Gets the world position input component
  20754. */
  20755. abstract get position(): NodeMaterialConnectionPoint;
  20756. /**
  20757. * Gets the world position input component
  20758. */
  20759. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20760. /**
  20761. * Gets the world normal input component
  20762. */
  20763. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20764. /**
  20765. * Gets the world input component
  20766. */
  20767. abstract get world(): NodeMaterialConnectionPoint;
  20768. /**
  20769. * Gets the camera (or eye) position component
  20770. */
  20771. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20772. /**
  20773. * Gets the view input component
  20774. */
  20775. abstract get view(): NodeMaterialConnectionPoint;
  20776. protected _getTexture(): Nullable<BaseTexture>;
  20777. autoConfigure(material: NodeMaterial): void;
  20778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20779. isReady(): boolean;
  20780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20781. /**
  20782. * Gets the code to inject in the vertex shader
  20783. * @param state current state of the node material building
  20784. * @returns the shader code
  20785. */
  20786. handleVertexSide(state: NodeMaterialBuildState): string;
  20787. /**
  20788. * Handles the inits for the fragment code path
  20789. * @param state node material build state
  20790. */
  20791. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20792. /**
  20793. * Generates the reflection coords code for the fragment code path
  20794. * @param worldNormalVarName name of the world normal variable
  20795. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20796. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20797. * @returns the shader code
  20798. */
  20799. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20800. /**
  20801. * Generates the reflection color code for the fragment code path
  20802. * @param lodVarName name of the lod variable
  20803. * @param swizzleLookupTexture swizzle to use for the final color variable
  20804. * @returns the shader code
  20805. */
  20806. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20807. /**
  20808. * Generates the code corresponding to the connected output points
  20809. * @param state node material build state
  20810. * @param varName name of the variable to output
  20811. * @returns the shader code
  20812. */
  20813. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20814. protected _buildBlock(state: NodeMaterialBuildState): this;
  20815. protected _dumpPropertiesCode(): string;
  20816. serialize(): any;
  20817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20818. }
  20819. }
  20820. declare module BABYLON {
  20821. /**
  20822. * Defines a connection point to be used for points with a custom object type
  20823. */
  20824. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20825. private _blockType;
  20826. private _blockName;
  20827. private _nameForCheking?;
  20828. /**
  20829. * Creates a new connection point
  20830. * @param name defines the connection point name
  20831. * @param ownerBlock defines the block hosting this connection point
  20832. * @param direction defines the direction of the connection point
  20833. */
  20834. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20835. /**
  20836. * Gets a number indicating if the current point can be connected to another point
  20837. * @param connectionPoint defines the other connection point
  20838. * @returns a number defining the compatibility state
  20839. */
  20840. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20841. /**
  20842. * Creates a block suitable to be used as an input for this input point.
  20843. * If null is returned, a block based on the point type will be created.
  20844. * @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
  20845. */
  20846. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20847. }
  20848. }
  20849. declare module BABYLON {
  20850. /**
  20851. * Enum defining the type of properties that can be edited in the property pages in the NME
  20852. */
  20853. export enum PropertyTypeForEdition {
  20854. /** property is a boolean */
  20855. Boolean = 0,
  20856. /** property is a float */
  20857. Float = 1,
  20858. /** property is a Vector2 */
  20859. Vector2 = 2,
  20860. /** property is a list of values */
  20861. List = 3
  20862. }
  20863. /**
  20864. * Interface that defines an option in a variable of type list
  20865. */
  20866. export interface IEditablePropertyListOption {
  20867. /** label of the option */
  20868. "label": string;
  20869. /** value of the option */
  20870. "value": number;
  20871. }
  20872. /**
  20873. * Interface that defines the options available for an editable property
  20874. */
  20875. export interface IEditablePropertyOption {
  20876. /** min value */
  20877. "min"?: number;
  20878. /** max value */
  20879. "max"?: number;
  20880. /** notifiers: indicates which actions to take when the property is changed */
  20881. "notifiers"?: {
  20882. /** the material should be rebuilt */
  20883. "rebuild"?: boolean;
  20884. /** the preview should be updated */
  20885. "update"?: boolean;
  20886. };
  20887. /** list of the options for a variable of type list */
  20888. "options"?: IEditablePropertyListOption[];
  20889. }
  20890. /**
  20891. * Interface that describes an editable property
  20892. */
  20893. export interface IPropertyDescriptionForEdition {
  20894. /** name of the property */
  20895. "propertyName": string;
  20896. /** display name of the property */
  20897. "displayName": string;
  20898. /** type of the property */
  20899. "type": PropertyTypeForEdition;
  20900. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20901. "groupName": string;
  20902. /** options for the property */
  20903. "options": IEditablePropertyOption;
  20904. }
  20905. /**
  20906. * Decorator that flags a property in a node material block as being editable
  20907. */
  20908. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20909. }
  20910. declare module BABYLON {
  20911. /**
  20912. * Block used to implement the refraction part of the sub surface module of the PBR material
  20913. */
  20914. export class RefractionBlock extends NodeMaterialBlock {
  20915. /** @hidden */
  20916. _define3DName: string;
  20917. /** @hidden */
  20918. _refractionMatrixName: string;
  20919. /** @hidden */
  20920. _defineLODRefractionAlpha: string;
  20921. /** @hidden */
  20922. _defineLinearSpecularRefraction: string;
  20923. /** @hidden */
  20924. _defineOppositeZ: string;
  20925. /** @hidden */
  20926. _cubeSamplerName: string;
  20927. /** @hidden */
  20928. _2DSamplerName: string;
  20929. /** @hidden */
  20930. _vRefractionMicrosurfaceInfosName: string;
  20931. /** @hidden */
  20932. _vRefractionInfosName: string;
  20933. private _scene;
  20934. /**
  20935. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20936. * Materials half opaque for instance using refraction could benefit from this control.
  20937. */
  20938. linkRefractionWithTransparency: boolean;
  20939. /**
  20940. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20941. */
  20942. invertRefractionY: boolean;
  20943. /**
  20944. * Gets or sets the texture associated with the node
  20945. */
  20946. texture: Nullable<BaseTexture>;
  20947. /**
  20948. * Create a new RefractionBlock
  20949. * @param name defines the block name
  20950. */
  20951. constructor(name: string);
  20952. /**
  20953. * Gets the current class name
  20954. * @returns the class name
  20955. */
  20956. getClassName(): string;
  20957. /**
  20958. * Gets the intensity input component
  20959. */
  20960. get intensity(): NodeMaterialConnectionPoint;
  20961. /**
  20962. * Gets the index of refraction input component
  20963. */
  20964. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20965. /**
  20966. * Gets the tint at distance input component
  20967. */
  20968. get tintAtDistance(): NodeMaterialConnectionPoint;
  20969. /**
  20970. * Gets the view input component
  20971. */
  20972. get view(): NodeMaterialConnectionPoint;
  20973. /**
  20974. * Gets the refraction object output component
  20975. */
  20976. get refraction(): NodeMaterialConnectionPoint;
  20977. /**
  20978. * Returns true if the block has a texture
  20979. */
  20980. get hasTexture(): boolean;
  20981. protected _getTexture(): Nullable<BaseTexture>;
  20982. autoConfigure(material: NodeMaterial): void;
  20983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20984. isReady(): boolean;
  20985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20986. /**
  20987. * Gets the main code of the block (fragment side)
  20988. * @param state current state of the node material building
  20989. * @returns the shader code
  20990. */
  20991. getCode(state: NodeMaterialBuildState): string;
  20992. protected _buildBlock(state: NodeMaterialBuildState): this;
  20993. protected _dumpPropertiesCode(): string;
  20994. serialize(): any;
  20995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20996. }
  20997. }
  20998. declare module BABYLON {
  20999. /**
  21000. * Base block used as input for post process
  21001. */
  21002. export class CurrentScreenBlock extends NodeMaterialBlock {
  21003. private _samplerName;
  21004. private _linearDefineName;
  21005. private _gammaDefineName;
  21006. private _mainUVName;
  21007. private _tempTextureRead;
  21008. /**
  21009. * Gets or sets the texture associated with the node
  21010. */
  21011. texture: Nullable<BaseTexture>;
  21012. /**
  21013. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21014. */
  21015. convertToGammaSpace: boolean;
  21016. /**
  21017. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21018. */
  21019. convertToLinearSpace: boolean;
  21020. /**
  21021. * Create a new CurrentScreenBlock
  21022. * @param name defines the block name
  21023. */
  21024. constructor(name: string);
  21025. /**
  21026. * Gets the current class name
  21027. * @returns the class name
  21028. */
  21029. getClassName(): string;
  21030. /**
  21031. * Gets the uv input component
  21032. */
  21033. get uv(): NodeMaterialConnectionPoint;
  21034. /**
  21035. * Gets the rgba output component
  21036. */
  21037. get rgba(): NodeMaterialConnectionPoint;
  21038. /**
  21039. * Gets the rgb output component
  21040. */
  21041. get rgb(): NodeMaterialConnectionPoint;
  21042. /**
  21043. * Gets the r output component
  21044. */
  21045. get r(): NodeMaterialConnectionPoint;
  21046. /**
  21047. * Gets the g output component
  21048. */
  21049. get g(): NodeMaterialConnectionPoint;
  21050. /**
  21051. * Gets the b output component
  21052. */
  21053. get b(): NodeMaterialConnectionPoint;
  21054. /**
  21055. * Gets the a output component
  21056. */
  21057. get a(): NodeMaterialConnectionPoint;
  21058. /**
  21059. * Initialize the block and prepare the context for build
  21060. * @param state defines the state that will be used for the build
  21061. */
  21062. initialize(state: NodeMaterialBuildState): void;
  21063. get target(): NodeMaterialBlockTargets;
  21064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21065. isReady(): boolean;
  21066. private _injectVertexCode;
  21067. private _writeTextureRead;
  21068. private _writeOutput;
  21069. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21070. serialize(): any;
  21071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21072. }
  21073. }
  21074. declare module BABYLON {
  21075. /**
  21076. * Base block used for the particle texture
  21077. */
  21078. export class ParticleTextureBlock extends NodeMaterialBlock {
  21079. private _samplerName;
  21080. private _linearDefineName;
  21081. private _gammaDefineName;
  21082. private _tempTextureRead;
  21083. /**
  21084. * Gets or sets the texture associated with the node
  21085. */
  21086. texture: Nullable<BaseTexture>;
  21087. /**
  21088. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21089. */
  21090. convertToGammaSpace: boolean;
  21091. /**
  21092. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21093. */
  21094. convertToLinearSpace: boolean;
  21095. /**
  21096. * Create a new ParticleTextureBlock
  21097. * @param name defines the block name
  21098. */
  21099. constructor(name: string);
  21100. /**
  21101. * Gets the current class name
  21102. * @returns the class name
  21103. */
  21104. getClassName(): string;
  21105. /**
  21106. * Gets the uv input component
  21107. */
  21108. get uv(): NodeMaterialConnectionPoint;
  21109. /**
  21110. * Gets the rgba output component
  21111. */
  21112. get rgba(): NodeMaterialConnectionPoint;
  21113. /**
  21114. * Gets the rgb output component
  21115. */
  21116. get rgb(): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Gets the r output component
  21119. */
  21120. get r(): NodeMaterialConnectionPoint;
  21121. /**
  21122. * Gets the g output component
  21123. */
  21124. get g(): NodeMaterialConnectionPoint;
  21125. /**
  21126. * Gets the b output component
  21127. */
  21128. get b(): NodeMaterialConnectionPoint;
  21129. /**
  21130. * Gets the a output component
  21131. */
  21132. get a(): NodeMaterialConnectionPoint;
  21133. /**
  21134. * Initialize the block and prepare the context for build
  21135. * @param state defines the state that will be used for the build
  21136. */
  21137. initialize(state: NodeMaterialBuildState): void;
  21138. autoConfigure(material: NodeMaterial): void;
  21139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21140. isReady(): boolean;
  21141. private _writeOutput;
  21142. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21143. serialize(): any;
  21144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21145. }
  21146. }
  21147. declare module BABYLON {
  21148. /**
  21149. * Class used to store shared data between 2 NodeMaterialBuildState
  21150. */
  21151. export class NodeMaterialBuildStateSharedData {
  21152. /**
  21153. * Gets the list of emitted varyings
  21154. */
  21155. temps: string[];
  21156. /**
  21157. * Gets the list of emitted varyings
  21158. */
  21159. varyings: string[];
  21160. /**
  21161. * Gets the varying declaration string
  21162. */
  21163. varyingDeclaration: string;
  21164. /**
  21165. * Input blocks
  21166. */
  21167. inputBlocks: InputBlock[];
  21168. /**
  21169. * Input blocks
  21170. */
  21171. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21172. /**
  21173. * Bindable blocks (Blocks that need to set data to the effect)
  21174. */
  21175. bindableBlocks: NodeMaterialBlock[];
  21176. /**
  21177. * List of blocks that can provide a compilation fallback
  21178. */
  21179. blocksWithFallbacks: NodeMaterialBlock[];
  21180. /**
  21181. * List of blocks that can provide a define update
  21182. */
  21183. blocksWithDefines: NodeMaterialBlock[];
  21184. /**
  21185. * List of blocks that can provide a repeatable content
  21186. */
  21187. repeatableContentBlocks: NodeMaterialBlock[];
  21188. /**
  21189. * List of blocks that can provide a dynamic list of uniforms
  21190. */
  21191. dynamicUniformBlocks: NodeMaterialBlock[];
  21192. /**
  21193. * List of blocks that can block the isReady function for the material
  21194. */
  21195. blockingBlocks: NodeMaterialBlock[];
  21196. /**
  21197. * Gets the list of animated inputs
  21198. */
  21199. animatedInputs: InputBlock[];
  21200. /**
  21201. * Build Id used to avoid multiple recompilations
  21202. */
  21203. buildId: number;
  21204. /** List of emitted variables */
  21205. variableNames: {
  21206. [key: string]: number;
  21207. };
  21208. /** List of emitted defines */
  21209. defineNames: {
  21210. [key: string]: number;
  21211. };
  21212. /** Should emit comments? */
  21213. emitComments: boolean;
  21214. /** Emit build activity */
  21215. verbose: boolean;
  21216. /** Gets or sets the hosting scene */
  21217. scene: Scene;
  21218. /**
  21219. * Gets the compilation hints emitted at compilation time
  21220. */
  21221. hints: {
  21222. needWorldViewMatrix: boolean;
  21223. needWorldViewProjectionMatrix: boolean;
  21224. needAlphaBlending: boolean;
  21225. needAlphaTesting: boolean;
  21226. };
  21227. /**
  21228. * List of compilation checks
  21229. */
  21230. checks: {
  21231. emitVertex: boolean;
  21232. emitFragment: boolean;
  21233. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21234. };
  21235. /**
  21236. * Is vertex program allowed to be empty?
  21237. */
  21238. allowEmptyVertexProgram: boolean;
  21239. /** Creates a new shared data */
  21240. constructor();
  21241. /**
  21242. * Emits console errors and exceptions if there is a failing check
  21243. */
  21244. emitErrors(): void;
  21245. }
  21246. }
  21247. declare module BABYLON {
  21248. /**
  21249. * Class used to store node based material build state
  21250. */
  21251. export class NodeMaterialBuildState {
  21252. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21253. supportUniformBuffers: boolean;
  21254. /**
  21255. * Gets the list of emitted attributes
  21256. */
  21257. attributes: string[];
  21258. /**
  21259. * Gets the list of emitted uniforms
  21260. */
  21261. uniforms: string[];
  21262. /**
  21263. * Gets the list of emitted constants
  21264. */
  21265. constants: string[];
  21266. /**
  21267. * Gets the list of emitted samplers
  21268. */
  21269. samplers: string[];
  21270. /**
  21271. * Gets the list of emitted functions
  21272. */
  21273. functions: {
  21274. [key: string]: string;
  21275. };
  21276. /**
  21277. * Gets the list of emitted extensions
  21278. */
  21279. extensions: {
  21280. [key: string]: string;
  21281. };
  21282. /**
  21283. * Gets the target of the compilation state
  21284. */
  21285. target: NodeMaterialBlockTargets;
  21286. /**
  21287. * Gets the list of emitted counters
  21288. */
  21289. counters: {
  21290. [key: string]: number;
  21291. };
  21292. /**
  21293. * Shared data between multiple NodeMaterialBuildState instances
  21294. */
  21295. sharedData: NodeMaterialBuildStateSharedData;
  21296. /** @hidden */
  21297. _vertexState: NodeMaterialBuildState;
  21298. /** @hidden */
  21299. _attributeDeclaration: string;
  21300. /** @hidden */
  21301. _uniformDeclaration: string;
  21302. /** @hidden */
  21303. _constantDeclaration: string;
  21304. /** @hidden */
  21305. _samplerDeclaration: string;
  21306. /** @hidden */
  21307. _varyingTransfer: string;
  21308. /** @hidden */
  21309. _injectAtEnd: string;
  21310. private _repeatableContentAnchorIndex;
  21311. /** @hidden */
  21312. _builtCompilationString: string;
  21313. /**
  21314. * Gets the emitted compilation strings
  21315. */
  21316. compilationString: string;
  21317. /**
  21318. * Finalize the compilation strings
  21319. * @param state defines the current compilation state
  21320. */
  21321. finalize(state: NodeMaterialBuildState): void;
  21322. /** @hidden */
  21323. get _repeatableContentAnchor(): string;
  21324. /** @hidden */
  21325. _getFreeVariableName(prefix: string): string;
  21326. /** @hidden */
  21327. _getFreeDefineName(prefix: string): string;
  21328. /** @hidden */
  21329. _excludeVariableName(name: string): void;
  21330. /** @hidden */
  21331. _emit2DSampler(name: string): void;
  21332. /** @hidden */
  21333. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21334. /** @hidden */
  21335. _emitExtension(name: string, extension: string, define?: string): void;
  21336. /** @hidden */
  21337. _emitFunction(name: string, code: string, comments: string): void;
  21338. /** @hidden */
  21339. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21340. replaceStrings?: {
  21341. search: RegExp;
  21342. replace: string;
  21343. }[];
  21344. repeatKey?: string;
  21345. }): string;
  21346. /** @hidden */
  21347. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21348. repeatKey?: string;
  21349. removeAttributes?: boolean;
  21350. removeUniforms?: boolean;
  21351. removeVaryings?: boolean;
  21352. removeIfDef?: boolean;
  21353. replaceStrings?: {
  21354. search: RegExp;
  21355. replace: string;
  21356. }[];
  21357. }, storeKey?: string): void;
  21358. /** @hidden */
  21359. _registerTempVariable(name: string): boolean;
  21360. /** @hidden */
  21361. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21362. /** @hidden */
  21363. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21364. /** @hidden */
  21365. _emitFloat(value: number): string;
  21366. }
  21367. }
  21368. declare module BABYLON {
  21369. /**
  21370. * Helper class used to generate session unique ID
  21371. */
  21372. export class UniqueIdGenerator {
  21373. private static _UniqueIdCounter;
  21374. /**
  21375. * Gets an unique (relatively to the current scene) Id
  21376. */
  21377. static get UniqueId(): number;
  21378. }
  21379. }
  21380. declare module BABYLON {
  21381. /**
  21382. * Defines a block that can be used inside a node based material
  21383. */
  21384. export class NodeMaterialBlock {
  21385. private _buildId;
  21386. private _buildTarget;
  21387. private _target;
  21388. private _isFinalMerger;
  21389. private _isInput;
  21390. private _name;
  21391. protected _isUnique: boolean;
  21392. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21393. inputsAreExclusive: boolean;
  21394. /** @hidden */
  21395. _codeVariableName: string;
  21396. /** @hidden */
  21397. _inputs: NodeMaterialConnectionPoint[];
  21398. /** @hidden */
  21399. _outputs: NodeMaterialConnectionPoint[];
  21400. /** @hidden */
  21401. _preparationId: number;
  21402. /**
  21403. * Gets the name of the block
  21404. */
  21405. get name(): string;
  21406. /**
  21407. * Sets the name of the block. Will check if the name is valid.
  21408. */
  21409. set name(newName: string);
  21410. /**
  21411. * Gets or sets the unique id of the node
  21412. */
  21413. uniqueId: number;
  21414. /**
  21415. * Gets or sets the comments associated with this block
  21416. */
  21417. comments: string;
  21418. /**
  21419. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21420. */
  21421. get isUnique(): boolean;
  21422. /**
  21423. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21424. */
  21425. get isFinalMerger(): boolean;
  21426. /**
  21427. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21428. */
  21429. get isInput(): boolean;
  21430. /**
  21431. * Gets or sets the build Id
  21432. */
  21433. get buildId(): number;
  21434. set buildId(value: number);
  21435. /**
  21436. * Gets or sets the target of the block
  21437. */
  21438. get target(): NodeMaterialBlockTargets;
  21439. set target(value: NodeMaterialBlockTargets);
  21440. /**
  21441. * Gets the list of input points
  21442. */
  21443. get inputs(): NodeMaterialConnectionPoint[];
  21444. /** Gets the list of output points */
  21445. get outputs(): NodeMaterialConnectionPoint[];
  21446. /**
  21447. * Find an input by its name
  21448. * @param name defines the name of the input to look for
  21449. * @returns the input or null if not found
  21450. */
  21451. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21452. /**
  21453. * Find an output by its name
  21454. * @param name defines the name of the outputto look for
  21455. * @returns the output or null if not found
  21456. */
  21457. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21458. /**
  21459. * Creates a new NodeMaterialBlock
  21460. * @param name defines the block name
  21461. * @param target defines the target of that block (Vertex by default)
  21462. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21463. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21464. */
  21465. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21466. /**
  21467. * Initialize the block and prepare the context for build
  21468. * @param state defines the state that will be used for the build
  21469. */
  21470. initialize(state: NodeMaterialBuildState): void;
  21471. /**
  21472. * Bind data to effect. Will only be called for blocks with isBindable === true
  21473. * @param effect defines the effect to bind data to
  21474. * @param nodeMaterial defines the hosting NodeMaterial
  21475. * @param mesh defines the mesh that will be rendered
  21476. * @param subMesh defines the submesh that will be rendered
  21477. */
  21478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21479. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21480. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21481. protected _writeFloat(value: number): string;
  21482. /**
  21483. * Gets the current class name e.g. "NodeMaterialBlock"
  21484. * @returns the class name
  21485. */
  21486. getClassName(): string;
  21487. /**
  21488. * Register a new input. Must be called inside a block constructor
  21489. * @param name defines the connection point name
  21490. * @param type defines the connection point type
  21491. * @param isOptional defines a boolean indicating that this input can be omitted
  21492. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21493. * @param point an already created connection point. If not provided, create a new one
  21494. * @returns the current block
  21495. */
  21496. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21497. /**
  21498. * Register a new output. Must be called inside a block constructor
  21499. * @param name defines the connection point name
  21500. * @param type defines the connection point type
  21501. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21502. * @param point an already created connection point. If not provided, create a new one
  21503. * @returns the current block
  21504. */
  21505. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21506. /**
  21507. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21508. * @param forOutput defines an optional connection point to check compatibility with
  21509. * @returns the first available input or null
  21510. */
  21511. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21512. /**
  21513. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21514. * @param forBlock defines an optional block to check compatibility with
  21515. * @returns the first available input or null
  21516. */
  21517. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21518. /**
  21519. * Gets the sibling of the given output
  21520. * @param current defines the current output
  21521. * @returns the next output in the list or null
  21522. */
  21523. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21524. /**
  21525. * Connect current block with another block
  21526. * @param other defines the block to connect with
  21527. * @param options define the various options to help pick the right connections
  21528. * @returns the current block
  21529. */
  21530. connectTo(other: NodeMaterialBlock, options?: {
  21531. input?: string;
  21532. output?: string;
  21533. outputSwizzle?: string;
  21534. }): this | undefined;
  21535. protected _buildBlock(state: NodeMaterialBuildState): void;
  21536. /**
  21537. * Add uniforms, samplers and uniform buffers at compilation time
  21538. * @param state defines the state to update
  21539. * @param nodeMaterial defines the node material requesting the update
  21540. * @param defines defines the material defines to update
  21541. * @param uniformBuffers defines the list of uniform buffer names
  21542. */
  21543. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21544. /**
  21545. * Add potential fallbacks if shader compilation fails
  21546. * @param mesh defines the mesh to be rendered
  21547. * @param fallbacks defines the current prioritized list of fallbacks
  21548. */
  21549. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21550. /**
  21551. * Initialize defines for shader compilation
  21552. * @param mesh defines the mesh to be rendered
  21553. * @param nodeMaterial defines the node material requesting the update
  21554. * @param defines defines the material defines to update
  21555. * @param useInstances specifies that instances should be used
  21556. */
  21557. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21558. /**
  21559. * Update defines for shader compilation
  21560. * @param mesh defines the mesh to be rendered
  21561. * @param nodeMaterial defines the node material requesting the update
  21562. * @param defines defines the material defines to update
  21563. * @param useInstances specifies that instances should be used
  21564. * @param subMesh defines which submesh to render
  21565. */
  21566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21567. /**
  21568. * Lets the block try to connect some inputs automatically
  21569. * @param material defines the hosting NodeMaterial
  21570. */
  21571. autoConfigure(material: NodeMaterial): void;
  21572. /**
  21573. * Function called when a block is declared as repeatable content generator
  21574. * @param vertexShaderState defines the current compilation state for the vertex shader
  21575. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21576. * @param mesh defines the mesh to be rendered
  21577. * @param defines defines the material defines to update
  21578. */
  21579. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21580. /**
  21581. * Checks if the block is ready
  21582. * @param mesh defines the mesh to be rendered
  21583. * @param nodeMaterial defines the node material requesting the update
  21584. * @param defines defines the material defines to update
  21585. * @param useInstances specifies that instances should be used
  21586. * @returns true if the block is ready
  21587. */
  21588. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21589. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21590. private _processBuild;
  21591. /**
  21592. * Validates the new name for the block node.
  21593. * @param newName the new name to be given to the node.
  21594. * @returns false if the name is a reserve word, else true.
  21595. */
  21596. validateBlockName(newName: string): boolean;
  21597. /**
  21598. * Compile the current node and generate the shader code
  21599. * @param state defines the current compilation state (uniforms, samplers, current string)
  21600. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21601. * @returns true if already built
  21602. */
  21603. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21604. protected _inputRename(name: string): string;
  21605. protected _outputRename(name: string): string;
  21606. protected _dumpPropertiesCode(): string;
  21607. /** @hidden */
  21608. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21609. /** @hidden */
  21610. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21611. /**
  21612. * Clone the current block to a new identical block
  21613. * @param scene defines the hosting scene
  21614. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21615. * @returns a copy of the current block
  21616. */
  21617. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21618. /**
  21619. * Serializes this block in a JSON representation
  21620. * @returns the serialized block object
  21621. */
  21622. serialize(): any;
  21623. /** @hidden */
  21624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21625. private _deserializePortDisplayNamesAndExposedOnFrame;
  21626. /**
  21627. * Release resources
  21628. */
  21629. dispose(): void;
  21630. }
  21631. }
  21632. declare module BABYLON {
  21633. /**
  21634. * Base class of materials working in push mode in babylon JS
  21635. * @hidden
  21636. */
  21637. export class PushMaterial extends Material {
  21638. protected _activeEffect: Effect;
  21639. protected _normalMatrix: Matrix;
  21640. constructor(name: string, scene: Scene);
  21641. getEffect(): Effect;
  21642. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21643. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21644. /**
  21645. * Binds the given world matrix to the active effect
  21646. *
  21647. * @param world the matrix to bind
  21648. */
  21649. bindOnlyWorldMatrix(world: Matrix): void;
  21650. /**
  21651. * Binds the given normal matrix to the active effect
  21652. *
  21653. * @param normalMatrix the matrix to bind
  21654. */
  21655. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21656. bind(world: Matrix, mesh?: Mesh): void;
  21657. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21658. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21659. }
  21660. }
  21661. declare module BABYLON {
  21662. /**
  21663. * Root class for all node material optimizers
  21664. */
  21665. export class NodeMaterialOptimizer {
  21666. /**
  21667. * Function used to optimize a NodeMaterial graph
  21668. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21669. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21670. */
  21671. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21672. }
  21673. }
  21674. declare module BABYLON {
  21675. /**
  21676. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21677. */
  21678. export class TransformBlock extends NodeMaterialBlock {
  21679. /**
  21680. * Defines the value to use to complement W value to transform it to a Vector4
  21681. */
  21682. complementW: number;
  21683. /**
  21684. * Defines the value to use to complement z value to transform it to a Vector4
  21685. */
  21686. complementZ: number;
  21687. /**
  21688. * Creates a new TransformBlock
  21689. * @param name defines the block name
  21690. */
  21691. constructor(name: string);
  21692. /**
  21693. * Gets the current class name
  21694. * @returns the class name
  21695. */
  21696. getClassName(): string;
  21697. /**
  21698. * Gets the vector input
  21699. */
  21700. get vector(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the output component
  21703. */
  21704. get output(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Gets the xyz output component
  21707. */
  21708. get xyz(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the matrix transform input
  21711. */
  21712. get transform(): NodeMaterialConnectionPoint;
  21713. protected _buildBlock(state: NodeMaterialBuildState): this;
  21714. /**
  21715. * Update defines for shader compilation
  21716. * @param mesh defines the mesh to be rendered
  21717. * @param nodeMaterial defines the node material requesting the update
  21718. * @param defines defines the material defines to update
  21719. * @param useInstances specifies that instances should be used
  21720. * @param subMesh defines which submesh to render
  21721. */
  21722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21723. serialize(): any;
  21724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21725. protected _dumpPropertiesCode(): string;
  21726. }
  21727. }
  21728. declare module BABYLON {
  21729. /**
  21730. * Block used to output the vertex position
  21731. */
  21732. export class VertexOutputBlock extends NodeMaterialBlock {
  21733. /**
  21734. * Creates a new VertexOutputBlock
  21735. * @param name defines the block name
  21736. */
  21737. constructor(name: string);
  21738. /**
  21739. * Gets the current class name
  21740. * @returns the class name
  21741. */
  21742. getClassName(): string;
  21743. /**
  21744. * Gets the vector input component
  21745. */
  21746. get vector(): NodeMaterialConnectionPoint;
  21747. protected _buildBlock(state: NodeMaterialBuildState): this;
  21748. }
  21749. }
  21750. declare module BABYLON {
  21751. /**
  21752. * Block used to output the final color
  21753. */
  21754. export class FragmentOutputBlock extends NodeMaterialBlock {
  21755. /**
  21756. * Create a new FragmentOutputBlock
  21757. * @param name defines the block name
  21758. */
  21759. constructor(name: string);
  21760. /**
  21761. * Gets the current class name
  21762. * @returns the class name
  21763. */
  21764. getClassName(): string;
  21765. /**
  21766. * Gets the rgba input component
  21767. */
  21768. get rgba(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the rgb input component
  21771. */
  21772. get rgb(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the a input component
  21775. */
  21776. get a(): NodeMaterialConnectionPoint;
  21777. protected _buildBlock(state: NodeMaterialBuildState): this;
  21778. }
  21779. }
  21780. declare module BABYLON {
  21781. /**
  21782. * Block used for the particle ramp gradient section
  21783. */
  21784. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21785. /**
  21786. * Create a new ParticleRampGradientBlock
  21787. * @param name defines the block name
  21788. */
  21789. constructor(name: string);
  21790. /**
  21791. * Gets the current class name
  21792. * @returns the class name
  21793. */
  21794. getClassName(): string;
  21795. /**
  21796. * Gets the color input component
  21797. */
  21798. get color(): NodeMaterialConnectionPoint;
  21799. /**
  21800. * Gets the rampColor output component
  21801. */
  21802. get rampColor(): NodeMaterialConnectionPoint;
  21803. /**
  21804. * Initialize the block and prepare the context for build
  21805. * @param state defines the state that will be used for the build
  21806. */
  21807. initialize(state: NodeMaterialBuildState): void;
  21808. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21809. }
  21810. }
  21811. declare module BABYLON {
  21812. /**
  21813. * Block used for the particle blend multiply section
  21814. */
  21815. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21816. /**
  21817. * Create a new ParticleBlendMultiplyBlock
  21818. * @param name defines the block name
  21819. */
  21820. constructor(name: string);
  21821. /**
  21822. * Gets the current class name
  21823. * @returns the class name
  21824. */
  21825. getClassName(): string;
  21826. /**
  21827. * Gets the color input component
  21828. */
  21829. get color(): NodeMaterialConnectionPoint;
  21830. /**
  21831. * Gets the alphaTexture input component
  21832. */
  21833. get alphaTexture(): NodeMaterialConnectionPoint;
  21834. /**
  21835. * Gets the alphaColor input component
  21836. */
  21837. get alphaColor(): NodeMaterialConnectionPoint;
  21838. /**
  21839. * Gets the blendColor output component
  21840. */
  21841. get blendColor(): NodeMaterialConnectionPoint;
  21842. /**
  21843. * Initialize the block and prepare the context for build
  21844. * @param state defines the state that will be used for the build
  21845. */
  21846. initialize(state: NodeMaterialBuildState): void;
  21847. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21848. }
  21849. }
  21850. declare module BABYLON {
  21851. /**
  21852. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21853. */
  21854. export class VectorMergerBlock extends NodeMaterialBlock {
  21855. /**
  21856. * Create a new VectorMergerBlock
  21857. * @param name defines the block name
  21858. */
  21859. constructor(name: string);
  21860. /**
  21861. * Gets the current class name
  21862. * @returns the class name
  21863. */
  21864. getClassName(): string;
  21865. /**
  21866. * Gets the xyz component (input)
  21867. */
  21868. get xyzIn(): NodeMaterialConnectionPoint;
  21869. /**
  21870. * Gets the xy component (input)
  21871. */
  21872. get xyIn(): NodeMaterialConnectionPoint;
  21873. /**
  21874. * Gets the x component (input)
  21875. */
  21876. get x(): NodeMaterialConnectionPoint;
  21877. /**
  21878. * Gets the y component (input)
  21879. */
  21880. get y(): NodeMaterialConnectionPoint;
  21881. /**
  21882. * Gets the z component (input)
  21883. */
  21884. get z(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the w component (input)
  21887. */
  21888. get w(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the xyzw component (output)
  21891. */
  21892. get xyzw(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the xyz component (output)
  21895. */
  21896. get xyzOut(): NodeMaterialConnectionPoint;
  21897. /**
  21898. * Gets the xy component (output)
  21899. */
  21900. get xyOut(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Gets the xy component (output)
  21903. * @deprecated Please use xyOut instead.
  21904. */
  21905. get xy(): NodeMaterialConnectionPoint;
  21906. /**
  21907. * Gets the xyz component (output)
  21908. * @deprecated Please use xyzOut instead.
  21909. */
  21910. get xyz(): NodeMaterialConnectionPoint;
  21911. protected _buildBlock(state: NodeMaterialBuildState): this;
  21912. }
  21913. }
  21914. declare module BABYLON {
  21915. /**
  21916. * Block used to remap a float from a range to a new one
  21917. */
  21918. export class RemapBlock extends NodeMaterialBlock {
  21919. /**
  21920. * Gets or sets the source range
  21921. */
  21922. sourceRange: Vector2;
  21923. /**
  21924. * Gets or sets the target range
  21925. */
  21926. targetRange: Vector2;
  21927. /**
  21928. * Creates a new RemapBlock
  21929. * @param name defines the block name
  21930. */
  21931. constructor(name: string);
  21932. /**
  21933. * Gets the current class name
  21934. * @returns the class name
  21935. */
  21936. getClassName(): string;
  21937. /**
  21938. * Gets the input component
  21939. */
  21940. get input(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the source min input component
  21943. */
  21944. get sourceMin(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the source max input component
  21947. */
  21948. get sourceMax(): NodeMaterialConnectionPoint;
  21949. /**
  21950. * Gets the target min input component
  21951. */
  21952. get targetMin(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the target max input component
  21955. */
  21956. get targetMax(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the output component
  21959. */
  21960. get output(): NodeMaterialConnectionPoint;
  21961. protected _buildBlock(state: NodeMaterialBuildState): this;
  21962. protected _dumpPropertiesCode(): string;
  21963. serialize(): any;
  21964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21965. }
  21966. }
  21967. declare module BABYLON {
  21968. /**
  21969. * Block used to multiply 2 values
  21970. */
  21971. export class MultiplyBlock extends NodeMaterialBlock {
  21972. /**
  21973. * Creates a new MultiplyBlock
  21974. * @param name defines the block name
  21975. */
  21976. constructor(name: string);
  21977. /**
  21978. * Gets the current class name
  21979. * @returns the class name
  21980. */
  21981. getClassName(): string;
  21982. /**
  21983. * Gets the left operand input component
  21984. */
  21985. get left(): NodeMaterialConnectionPoint;
  21986. /**
  21987. * Gets the right operand input component
  21988. */
  21989. get right(): NodeMaterialConnectionPoint;
  21990. /**
  21991. * Gets the output component
  21992. */
  21993. get output(): NodeMaterialConnectionPoint;
  21994. protected _buildBlock(state: NodeMaterialBuildState): this;
  21995. }
  21996. }
  21997. declare module BABYLON {
  21998. /**
  21999. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22000. */
  22001. export class ColorSplitterBlock extends NodeMaterialBlock {
  22002. /**
  22003. * Create a new ColorSplitterBlock
  22004. * @param name defines the block name
  22005. */
  22006. constructor(name: string);
  22007. /**
  22008. * Gets the current class name
  22009. * @returns the class name
  22010. */
  22011. getClassName(): string;
  22012. /**
  22013. * Gets the rgba component (input)
  22014. */
  22015. get rgba(): NodeMaterialConnectionPoint;
  22016. /**
  22017. * Gets the rgb component (input)
  22018. */
  22019. get rgbIn(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the rgb component (output)
  22022. */
  22023. get rgbOut(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the r component (output)
  22026. */
  22027. get r(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the g component (output)
  22030. */
  22031. get g(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the b component (output)
  22034. */
  22035. get b(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the a component (output)
  22038. */
  22039. get a(): NodeMaterialConnectionPoint;
  22040. protected _inputRename(name: string): string;
  22041. protected _outputRename(name: string): string;
  22042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22043. }
  22044. }
  22045. declare module BABYLON {
  22046. /**
  22047. * Interface used to configure the node material editor
  22048. */
  22049. export interface INodeMaterialEditorOptions {
  22050. /** Define the URl to load node editor script */
  22051. editorURL?: string;
  22052. }
  22053. /** @hidden */
  22054. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22055. NORMAL: boolean;
  22056. TANGENT: boolean;
  22057. UV1: boolean;
  22058. /** BONES */
  22059. NUM_BONE_INFLUENCERS: number;
  22060. BonesPerMesh: number;
  22061. BONETEXTURE: boolean;
  22062. /** MORPH TARGETS */
  22063. MORPHTARGETS: boolean;
  22064. MORPHTARGETS_NORMAL: boolean;
  22065. MORPHTARGETS_TANGENT: boolean;
  22066. MORPHTARGETS_UV: boolean;
  22067. NUM_MORPH_INFLUENCERS: number;
  22068. /** IMAGE PROCESSING */
  22069. IMAGEPROCESSING: boolean;
  22070. VIGNETTE: boolean;
  22071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22072. VIGNETTEBLENDMODEOPAQUE: boolean;
  22073. TONEMAPPING: boolean;
  22074. TONEMAPPING_ACES: boolean;
  22075. CONTRAST: boolean;
  22076. EXPOSURE: boolean;
  22077. COLORCURVES: boolean;
  22078. COLORGRADING: boolean;
  22079. COLORGRADING3D: boolean;
  22080. SAMPLER3DGREENDEPTH: boolean;
  22081. SAMPLER3DBGRMAP: boolean;
  22082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22083. /** MISC. */
  22084. BUMPDIRECTUV: number;
  22085. constructor();
  22086. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22087. }
  22088. /**
  22089. * Class used to configure NodeMaterial
  22090. */
  22091. export interface INodeMaterialOptions {
  22092. /**
  22093. * Defines if blocks should emit comments
  22094. */
  22095. emitComments: boolean;
  22096. }
  22097. /**
  22098. * Class used to create a node based material built by assembling shader blocks
  22099. */
  22100. export class NodeMaterial extends PushMaterial {
  22101. private static _BuildIdGenerator;
  22102. private _options;
  22103. private _vertexCompilationState;
  22104. private _fragmentCompilationState;
  22105. private _sharedData;
  22106. private _buildId;
  22107. private _buildWasSuccessful;
  22108. private _cachedWorldViewMatrix;
  22109. private _cachedWorldViewProjectionMatrix;
  22110. private _optimizers;
  22111. private _animationFrame;
  22112. /** Define the Url to load node editor script */
  22113. static EditorURL: string;
  22114. /** Define the Url to load snippets */
  22115. static SnippetUrl: string;
  22116. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22117. static IgnoreTexturesAtLoadTime: boolean;
  22118. private BJSNODEMATERIALEDITOR;
  22119. /** Get the inspector from bundle or global */
  22120. private _getGlobalNodeMaterialEditor;
  22121. /**
  22122. * Snippet ID if the material was created from the snippet server
  22123. */
  22124. snippetId: string;
  22125. /**
  22126. * Gets or sets data used by visual editor
  22127. * @see https://nme.babylonjs.com
  22128. */
  22129. editorData: any;
  22130. /**
  22131. * 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)
  22132. */
  22133. ignoreAlpha: boolean;
  22134. /**
  22135. * Defines the maximum number of lights that can be used in the material
  22136. */
  22137. maxSimultaneousLights: number;
  22138. /**
  22139. * Observable raised when the material is built
  22140. */
  22141. onBuildObservable: Observable<NodeMaterial>;
  22142. /**
  22143. * Gets or sets the root nodes of the material vertex shader
  22144. */
  22145. _vertexOutputNodes: NodeMaterialBlock[];
  22146. /**
  22147. * Gets or sets the root nodes of the material fragment (pixel) shader
  22148. */
  22149. _fragmentOutputNodes: NodeMaterialBlock[];
  22150. /** Gets or sets options to control the node material overall behavior */
  22151. get options(): INodeMaterialOptions;
  22152. set options(options: INodeMaterialOptions);
  22153. /**
  22154. * Default configuration related to image processing available in the standard Material.
  22155. */
  22156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22157. /**
  22158. * Gets the image processing configuration used either in this material.
  22159. */
  22160. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22161. /**
  22162. * Sets the Default image processing configuration used either in the this material.
  22163. *
  22164. * If sets to null, the scene one is in use.
  22165. */
  22166. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22167. /**
  22168. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22169. */
  22170. attachedBlocks: NodeMaterialBlock[];
  22171. /**
  22172. * Specifies the mode of the node material
  22173. * @hidden
  22174. */
  22175. _mode: NodeMaterialModes;
  22176. /**
  22177. * Gets the mode property
  22178. */
  22179. get mode(): NodeMaterialModes;
  22180. /**
  22181. * Create a new node based material
  22182. * @param name defines the material name
  22183. * @param scene defines the hosting scene
  22184. * @param options defines creation option
  22185. */
  22186. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22187. /**
  22188. * Gets the current class name of the material e.g. "NodeMaterial"
  22189. * @returns the class name
  22190. */
  22191. getClassName(): string;
  22192. /**
  22193. * Keep track of the image processing observer to allow dispose and replace.
  22194. */
  22195. private _imageProcessingObserver;
  22196. /**
  22197. * Attaches a new image processing configuration to the Standard Material.
  22198. * @param configuration
  22199. */
  22200. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22201. /**
  22202. * Get a block by its name
  22203. * @param name defines the name of the block to retrieve
  22204. * @returns the required block or null if not found
  22205. */
  22206. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22207. /**
  22208. * Get a block by its name
  22209. * @param predicate defines the predicate used to find the good candidate
  22210. * @returns the required block or null if not found
  22211. */
  22212. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22213. /**
  22214. * Get an input block by its name
  22215. * @param predicate defines the predicate used to find the good candidate
  22216. * @returns the required input block or null if not found
  22217. */
  22218. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22219. /**
  22220. * Gets the list of input blocks attached to this material
  22221. * @returns an array of InputBlocks
  22222. */
  22223. getInputBlocks(): InputBlock[];
  22224. /**
  22225. * Adds a new optimizer to the list of optimizers
  22226. * @param optimizer defines the optimizers to add
  22227. * @returns the current material
  22228. */
  22229. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22230. /**
  22231. * Remove an optimizer from the list of optimizers
  22232. * @param optimizer defines the optimizers to remove
  22233. * @returns the current material
  22234. */
  22235. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22236. /**
  22237. * Add a new block to the list of output nodes
  22238. * @param node defines the node to add
  22239. * @returns the current material
  22240. */
  22241. addOutputNode(node: NodeMaterialBlock): this;
  22242. /**
  22243. * Remove a block from the list of root nodes
  22244. * @param node defines the node to remove
  22245. * @returns the current material
  22246. */
  22247. removeOutputNode(node: NodeMaterialBlock): this;
  22248. private _addVertexOutputNode;
  22249. private _removeVertexOutputNode;
  22250. private _addFragmentOutputNode;
  22251. private _removeFragmentOutputNode;
  22252. /**
  22253. * Specifies if the material will require alpha blending
  22254. * @returns a boolean specifying if alpha blending is needed
  22255. */
  22256. needAlphaBlending(): boolean;
  22257. /**
  22258. * Specifies if this material should be rendered in alpha test mode
  22259. * @returns a boolean specifying if an alpha test is needed.
  22260. */
  22261. needAlphaTesting(): boolean;
  22262. private _initializeBlock;
  22263. private _resetDualBlocks;
  22264. /**
  22265. * Remove a block from the current node material
  22266. * @param block defines the block to remove
  22267. */
  22268. removeBlock(block: NodeMaterialBlock): void;
  22269. /**
  22270. * Build the material and generates the inner effect
  22271. * @param verbose defines if the build should log activity
  22272. */
  22273. build(verbose?: boolean): void;
  22274. /**
  22275. * Runs an otpimization phase to try to improve the shader code
  22276. */
  22277. optimize(): void;
  22278. private _prepareDefinesForAttributes;
  22279. /**
  22280. * Create a post process from the material
  22281. * @param camera The camera to apply the render pass to.
  22282. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22284. * @param engine The engine which the post process will be applied. (default: current engine)
  22285. * @param reusable If the post process can be reused on the same frame. (default: false)
  22286. * @param textureType Type of textures used when performing the post process. (default: 0)
  22287. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22288. * @returns the post process created
  22289. */
  22290. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22291. /**
  22292. * Create the post process effect from the material
  22293. * @param postProcess The post process to create the effect for
  22294. */
  22295. createEffectForPostProcess(postProcess: PostProcess): void;
  22296. private _createEffectOrPostProcess;
  22297. private _createEffectForParticles;
  22298. /**
  22299. * Create the effect to be used as the custom effect for a particle system
  22300. * @param particleSystem Particle system to create the effect for
  22301. * @param onCompiled defines a function to call when the effect creation is successful
  22302. * @param onError defines a function to call when the effect creation has failed
  22303. */
  22304. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22305. private _processDefines;
  22306. /**
  22307. * Get if the submesh is ready to be used and all its information available.
  22308. * Child classes can use it to update shaders
  22309. * @param mesh defines the mesh to check
  22310. * @param subMesh defines which submesh to check
  22311. * @param useInstances specifies that instances should be used
  22312. * @returns a boolean indicating that the submesh is ready or not
  22313. */
  22314. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22315. /**
  22316. * Get a string representing the shaders built by the current node graph
  22317. */
  22318. get compiledShaders(): string;
  22319. /**
  22320. * Binds the world matrix to the material
  22321. * @param world defines the world transformation matrix
  22322. */
  22323. bindOnlyWorldMatrix(world: Matrix): void;
  22324. /**
  22325. * Binds the submesh to this material by preparing the effect and shader to draw
  22326. * @param world defines the world transformation matrix
  22327. * @param mesh defines the mesh containing the submesh
  22328. * @param subMesh defines the submesh to bind the material to
  22329. */
  22330. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22331. /**
  22332. * Gets the active textures from the material
  22333. * @returns an array of textures
  22334. */
  22335. getActiveTextures(): BaseTexture[];
  22336. /**
  22337. * Gets the list of texture blocks
  22338. * @returns an array of texture blocks
  22339. */
  22340. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22341. /**
  22342. * Specifies if the material uses a texture
  22343. * @param texture defines the texture to check against the material
  22344. * @returns a boolean specifying if the material uses the texture
  22345. */
  22346. hasTexture(texture: BaseTexture): boolean;
  22347. /**
  22348. * Disposes the material
  22349. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22350. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22351. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22352. */
  22353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22354. /** Creates the node editor window. */
  22355. private _createNodeEditor;
  22356. /**
  22357. * Launch the node material editor
  22358. * @param config Define the configuration of the editor
  22359. * @return a promise fulfilled when the node editor is visible
  22360. */
  22361. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22362. /**
  22363. * Clear the current material
  22364. */
  22365. clear(): void;
  22366. /**
  22367. * Clear the current material and set it to a default state
  22368. */
  22369. setToDefault(): void;
  22370. /**
  22371. * Clear the current material and set it to a default state for post process
  22372. */
  22373. setToDefaultPostProcess(): void;
  22374. /**
  22375. * Clear the current material and set it to a default state for particle
  22376. */
  22377. setToDefaultParticle(): void;
  22378. /**
  22379. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22380. * @param url defines the url to load from
  22381. * @returns a promise that will fullfil when the material is fully loaded
  22382. */
  22383. loadAsync(url: string): Promise<void>;
  22384. private _gatherBlocks;
  22385. /**
  22386. * Generate a string containing the code declaration required to create an equivalent of this material
  22387. * @returns a string
  22388. */
  22389. generateCode(): string;
  22390. /**
  22391. * Serializes this material in a JSON representation
  22392. * @returns the serialized material object
  22393. */
  22394. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22395. private _restoreConnections;
  22396. /**
  22397. * Clear the current graph and load a new one from a serialization object
  22398. * @param source defines the JSON representation of the material
  22399. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22400. * @param merge defines whether or not the source must be merged or replace the current content
  22401. */
  22402. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22403. /**
  22404. * Makes a duplicate of the current material.
  22405. * @param name - name to use for the new material.
  22406. */
  22407. clone(name: string): NodeMaterial;
  22408. /**
  22409. * Creates a node material from parsed material data
  22410. * @param source defines the JSON representation of the material
  22411. * @param scene defines the hosting scene
  22412. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22413. * @returns a new node material
  22414. */
  22415. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22416. /**
  22417. * Creates a node material from a snippet saved in a remote file
  22418. * @param name defines the name of the material to create
  22419. * @param url defines the url to load from
  22420. * @param scene defines the hosting scene
  22421. * @returns a promise that will resolve to the new node material
  22422. */
  22423. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22424. /**
  22425. * Creates a node material from a snippet saved by the node material editor
  22426. * @param snippetId defines the snippet to load
  22427. * @param scene defines the hosting scene
  22428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22429. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22430. * @returns a promise that will resolve to the new node material
  22431. */
  22432. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22433. /**
  22434. * Creates a new node material set to default basic configuration
  22435. * @param name defines the name of the material
  22436. * @param scene defines the hosting scene
  22437. * @returns a new NodeMaterial
  22438. */
  22439. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22440. }
  22441. }
  22442. declare module BABYLON {
  22443. /**
  22444. * Size options for a post process
  22445. */
  22446. export type PostProcessOptions = {
  22447. width: number;
  22448. height: number;
  22449. };
  22450. /**
  22451. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22452. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22453. */
  22454. export class PostProcess {
  22455. /** Name of the PostProcess. */
  22456. name: string;
  22457. /**
  22458. * Gets or sets the unique id of the post process
  22459. */
  22460. uniqueId: number;
  22461. /**
  22462. * Width of the texture to apply the post process on
  22463. */
  22464. width: number;
  22465. /**
  22466. * Height of the texture to apply the post process on
  22467. */
  22468. height: number;
  22469. /**
  22470. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22471. */
  22472. nodeMaterialSource: Nullable<NodeMaterial>;
  22473. /**
  22474. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22475. * @hidden
  22476. */
  22477. _outputTexture: Nullable<InternalTexture>;
  22478. /**
  22479. * Sampling mode used by the shader
  22480. * See https://doc.babylonjs.com/classes/3.1/texture
  22481. */
  22482. renderTargetSamplingMode: number;
  22483. /**
  22484. * Clear color to use when screen clearing
  22485. */
  22486. clearColor: Color4;
  22487. /**
  22488. * If the buffer needs to be cleared before applying the post process. (default: true)
  22489. * Should be set to false if shader will overwrite all previous pixels.
  22490. */
  22491. autoClear: boolean;
  22492. /**
  22493. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22494. */
  22495. alphaMode: number;
  22496. /**
  22497. * Sets the setAlphaBlendConstants of the babylon engine
  22498. */
  22499. alphaConstants: Color4;
  22500. /**
  22501. * Animations to be used for the post processing
  22502. */
  22503. animations: Animation[];
  22504. /**
  22505. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22506. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22507. */
  22508. enablePixelPerfectMode: boolean;
  22509. /**
  22510. * Force the postprocess to be applied without taking in account viewport
  22511. */
  22512. forceFullscreenViewport: boolean;
  22513. /**
  22514. * List of inspectable custom properties (used by the Inspector)
  22515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22516. */
  22517. inspectableCustomProperties: IInspectable[];
  22518. /**
  22519. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22520. *
  22521. * | Value | Type | Description |
  22522. * | ----- | ----------------------------------- | ----------- |
  22523. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22524. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22525. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22526. *
  22527. */
  22528. scaleMode: number;
  22529. /**
  22530. * Force textures to be a power of two (default: false)
  22531. */
  22532. alwaysForcePOT: boolean;
  22533. private _samples;
  22534. /**
  22535. * Number of sample textures (default: 1)
  22536. */
  22537. get samples(): number;
  22538. set samples(n: number);
  22539. /**
  22540. * Modify the scale of the post process to be the same as the viewport (default: false)
  22541. */
  22542. adaptScaleToCurrentViewport: boolean;
  22543. private _camera;
  22544. protected _scene: Scene;
  22545. private _engine;
  22546. private _options;
  22547. private _reusable;
  22548. private _textureType;
  22549. private _textureFormat;
  22550. /**
  22551. * Smart array of input and output textures for the post process.
  22552. * @hidden
  22553. */
  22554. _textures: SmartArray<InternalTexture>;
  22555. /**
  22556. * The index in _textures that corresponds to the output texture.
  22557. * @hidden
  22558. */
  22559. _currentRenderTextureInd: number;
  22560. private _effect;
  22561. private _samplers;
  22562. private _fragmentUrl;
  22563. private _vertexUrl;
  22564. private _parameters;
  22565. private _scaleRatio;
  22566. protected _indexParameters: any;
  22567. private _shareOutputWithPostProcess;
  22568. private _texelSize;
  22569. private _forcedOutputTexture;
  22570. /**
  22571. * Returns the fragment url or shader name used in the post process.
  22572. * @returns the fragment url or name in the shader store.
  22573. */
  22574. getEffectName(): string;
  22575. /**
  22576. * An event triggered when the postprocess is activated.
  22577. */
  22578. onActivateObservable: Observable<Camera>;
  22579. private _onActivateObserver;
  22580. /**
  22581. * A function that is added to the onActivateObservable
  22582. */
  22583. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22584. /**
  22585. * An event triggered when the postprocess changes its size.
  22586. */
  22587. onSizeChangedObservable: Observable<PostProcess>;
  22588. private _onSizeChangedObserver;
  22589. /**
  22590. * A function that is added to the onSizeChangedObservable
  22591. */
  22592. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22593. /**
  22594. * An event triggered when the postprocess applies its effect.
  22595. */
  22596. onApplyObservable: Observable<Effect>;
  22597. private _onApplyObserver;
  22598. /**
  22599. * A function that is added to the onApplyObservable
  22600. */
  22601. set onApply(callback: (effect: Effect) => void);
  22602. /**
  22603. * An event triggered before rendering the postprocess
  22604. */
  22605. onBeforeRenderObservable: Observable<Effect>;
  22606. private _onBeforeRenderObserver;
  22607. /**
  22608. * A function that is added to the onBeforeRenderObservable
  22609. */
  22610. set onBeforeRender(callback: (effect: Effect) => void);
  22611. /**
  22612. * An event triggered after rendering the postprocess
  22613. */
  22614. onAfterRenderObservable: Observable<Effect>;
  22615. private _onAfterRenderObserver;
  22616. /**
  22617. * A function that is added to the onAfterRenderObservable
  22618. */
  22619. set onAfterRender(callback: (efect: Effect) => void);
  22620. /**
  22621. * 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
  22622. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22623. */
  22624. get inputTexture(): InternalTexture;
  22625. set inputTexture(value: InternalTexture);
  22626. /**
  22627. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22628. * the only way to unset it is to use this function to restore its internal state
  22629. */
  22630. restoreDefaultInputTexture(): void;
  22631. /**
  22632. * Gets the camera which post process is applied to.
  22633. * @returns The camera the post process is applied to.
  22634. */
  22635. getCamera(): Camera;
  22636. /**
  22637. * Gets the texel size of the postprocess.
  22638. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22639. */
  22640. get texelSize(): Vector2;
  22641. /**
  22642. * Creates a new instance PostProcess
  22643. * @param name The name of the PostProcess.
  22644. * @param fragmentUrl The url of the fragment shader to be used.
  22645. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22646. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22647. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22648. * @param camera The camera to apply the render pass to.
  22649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22650. * @param engine The engine which the post process will be applied. (default: current engine)
  22651. * @param reusable If the post process can be reused on the same frame. (default: false)
  22652. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22653. * @param textureType Type of textures used when performing the post process. (default: 0)
  22654. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22655. * @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
  22656. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22657. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22658. */
  22659. constructor(
  22660. /** Name of the PostProcess. */
  22661. 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);
  22662. /**
  22663. * Gets a string idenfifying the name of the class
  22664. * @returns "PostProcess" string
  22665. */
  22666. getClassName(): string;
  22667. /**
  22668. * Gets the engine which this post process belongs to.
  22669. * @returns The engine the post process was enabled with.
  22670. */
  22671. getEngine(): Engine;
  22672. /**
  22673. * The effect that is created when initializing the post process.
  22674. * @returns The created effect corresponding the the postprocess.
  22675. */
  22676. getEffect(): Effect;
  22677. /**
  22678. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22679. * @param postProcess The post process to share the output with.
  22680. * @returns This post process.
  22681. */
  22682. shareOutputWith(postProcess: PostProcess): PostProcess;
  22683. /**
  22684. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22685. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22686. */
  22687. useOwnOutput(): void;
  22688. /**
  22689. * Updates the effect with the current post process compile time values and recompiles the shader.
  22690. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22691. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22692. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22693. * @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
  22694. * @param onCompiled Called when the shader has been compiled.
  22695. * @param onError Called if there is an error when compiling a shader.
  22696. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22697. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22698. */
  22699. 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;
  22700. /**
  22701. * The post process is reusable if it can be used multiple times within one frame.
  22702. * @returns If the post process is reusable
  22703. */
  22704. isReusable(): boolean;
  22705. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22706. markTextureDirty(): void;
  22707. /**
  22708. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22709. * 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.
  22710. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22711. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22712. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22713. * @returns The target texture that was bound to be written to.
  22714. */
  22715. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22716. /**
  22717. * If the post process is supported.
  22718. */
  22719. get isSupported(): boolean;
  22720. /**
  22721. * The aspect ratio of the output texture.
  22722. */
  22723. get aspectRatio(): number;
  22724. /**
  22725. * Get a value indicating if the post-process is ready to be used
  22726. * @returns true if the post-process is ready (shader is compiled)
  22727. */
  22728. isReady(): boolean;
  22729. /**
  22730. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22731. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22732. */
  22733. apply(): Nullable<Effect>;
  22734. private _disposeTextures;
  22735. /**
  22736. * Disposes the post process.
  22737. * @param camera The camera to dispose the post process on.
  22738. */
  22739. dispose(camera?: Camera): void;
  22740. }
  22741. }
  22742. declare module BABYLON {
  22743. /** @hidden */
  22744. export var kernelBlurVaryingDeclaration: {
  22745. name: string;
  22746. shader: string;
  22747. };
  22748. }
  22749. declare module BABYLON {
  22750. /** @hidden */
  22751. export var kernelBlurFragment: {
  22752. name: string;
  22753. shader: string;
  22754. };
  22755. }
  22756. declare module BABYLON {
  22757. /** @hidden */
  22758. export var kernelBlurFragment2: {
  22759. name: string;
  22760. shader: string;
  22761. };
  22762. }
  22763. declare module BABYLON {
  22764. /** @hidden */
  22765. export var kernelBlurPixelShader: {
  22766. name: string;
  22767. shader: string;
  22768. };
  22769. }
  22770. declare module BABYLON {
  22771. /** @hidden */
  22772. export var kernelBlurVertex: {
  22773. name: string;
  22774. shader: string;
  22775. };
  22776. }
  22777. declare module BABYLON {
  22778. /** @hidden */
  22779. export var kernelBlurVertexShader: {
  22780. name: string;
  22781. shader: string;
  22782. };
  22783. }
  22784. declare module BABYLON {
  22785. /**
  22786. * The Blur Post Process which blurs an image based on a kernel and direction.
  22787. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22788. */
  22789. export class BlurPostProcess extends PostProcess {
  22790. /** The direction in which to blur the image. */
  22791. direction: Vector2;
  22792. private blockCompilation;
  22793. protected _kernel: number;
  22794. protected _idealKernel: number;
  22795. protected _packedFloat: boolean;
  22796. private _staticDefines;
  22797. /**
  22798. * Sets the length in pixels of the blur sample region
  22799. */
  22800. set kernel(v: number);
  22801. /**
  22802. * Gets the length in pixels of the blur sample region
  22803. */
  22804. get kernel(): number;
  22805. /**
  22806. * Sets wether or not the blur needs to unpack/repack floats
  22807. */
  22808. set packedFloat(v: boolean);
  22809. /**
  22810. * Gets wether or not the blur is unpacking/repacking floats
  22811. */
  22812. get packedFloat(): boolean;
  22813. /**
  22814. * Creates a new instance BlurPostProcess
  22815. * @param name The name of the effect.
  22816. * @param direction The direction in which to blur the image.
  22817. * @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.
  22818. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22819. * @param camera The camera to apply the render pass to.
  22820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22821. * @param engine The engine which the post process will be applied. (default: current engine)
  22822. * @param reusable If the post process can be reused on the same frame. (default: false)
  22823. * @param textureType Type of textures used when performing the post process. (default: 0)
  22824. * @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)
  22825. */
  22826. constructor(name: string,
  22827. /** The direction in which to blur the image. */
  22828. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22829. /**
  22830. * Updates the effect with the current post process compile time values and recompiles the shader.
  22831. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22832. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22833. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22834. * @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
  22835. * @param onCompiled Called when the shader has been compiled.
  22836. * @param onError Called if there is an error when compiling a shader.
  22837. */
  22838. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22839. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22840. /**
  22841. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22842. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22843. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22844. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22845. * The gaps between physical kernels are compensated for in the weighting of the samples
  22846. * @param idealKernel Ideal blur kernel.
  22847. * @return Nearest best kernel.
  22848. */
  22849. protected _nearestBestKernel(idealKernel: number): number;
  22850. /**
  22851. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22852. * @param x The point on the Gaussian distribution to sample.
  22853. * @return the value of the Gaussian function at x.
  22854. */
  22855. protected _gaussianWeight(x: number): number;
  22856. /**
  22857. * Generates a string that can be used as a floating point number in GLSL.
  22858. * @param x Value to print.
  22859. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22860. * @return GLSL float string.
  22861. */
  22862. protected _glslFloat(x: number, decimalFigures?: number): string;
  22863. }
  22864. }
  22865. declare module BABYLON {
  22866. /**
  22867. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22868. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22869. * You can then easily use it as a reflectionTexture on a flat surface.
  22870. * In case the surface is not a plane, please consider relying on reflection probes.
  22871. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22872. */
  22873. export class MirrorTexture extends RenderTargetTexture {
  22874. private scene;
  22875. /**
  22876. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22877. * 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.
  22878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22879. */
  22880. mirrorPlane: Plane;
  22881. /**
  22882. * Define the blur ratio used to blur the reflection if needed.
  22883. */
  22884. set blurRatio(value: number);
  22885. get blurRatio(): number;
  22886. /**
  22887. * Define the adaptive blur kernel used to blur the reflection if needed.
  22888. * This will autocompute the closest best match for the `blurKernel`
  22889. */
  22890. set adaptiveBlurKernel(value: number);
  22891. /**
  22892. * Define the blur kernel used to blur the reflection if needed.
  22893. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22894. */
  22895. set blurKernel(value: number);
  22896. /**
  22897. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22898. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22899. */
  22900. set blurKernelX(value: number);
  22901. get blurKernelX(): number;
  22902. /**
  22903. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22904. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22905. */
  22906. set blurKernelY(value: number);
  22907. get blurKernelY(): number;
  22908. private _autoComputeBlurKernel;
  22909. protected _onRatioRescale(): void;
  22910. private _updateGammaSpace;
  22911. private _imageProcessingConfigChangeObserver;
  22912. private _transformMatrix;
  22913. private _mirrorMatrix;
  22914. private _savedViewMatrix;
  22915. private _blurX;
  22916. private _blurY;
  22917. private _adaptiveBlurKernel;
  22918. private _blurKernelX;
  22919. private _blurKernelY;
  22920. private _blurRatio;
  22921. /**
  22922. * Instantiates a Mirror Texture.
  22923. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22924. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22925. * You can then easily use it as a reflectionTexture on a flat surface.
  22926. * In case the surface is not a plane, please consider relying on reflection probes.
  22927. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22928. * @param name
  22929. * @param size
  22930. * @param scene
  22931. * @param generateMipMaps
  22932. * @param type
  22933. * @param samplingMode
  22934. * @param generateDepthBuffer
  22935. */
  22936. constructor(name: string, size: number | {
  22937. width: number;
  22938. height: number;
  22939. } | {
  22940. ratio: number;
  22941. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22942. private _preparePostProcesses;
  22943. /**
  22944. * Clone the mirror texture.
  22945. * @returns the cloned texture
  22946. */
  22947. clone(): MirrorTexture;
  22948. /**
  22949. * Serialize the texture to a JSON representation you could use in Parse later on
  22950. * @returns the serialized JSON representation
  22951. */
  22952. serialize(): any;
  22953. /**
  22954. * Dispose the texture and release its associated resources.
  22955. */
  22956. dispose(): void;
  22957. }
  22958. }
  22959. declare module BABYLON {
  22960. /**
  22961. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22962. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22963. */
  22964. export class Texture extends BaseTexture {
  22965. /**
  22966. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22967. */
  22968. static SerializeBuffers: boolean;
  22969. /** @hidden */
  22970. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22971. /** @hidden */
  22972. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22973. /** @hidden */
  22974. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22975. /** nearest is mag = nearest and min = nearest and mip = linear */
  22976. static readonly NEAREST_SAMPLINGMODE: number;
  22977. /** nearest is mag = nearest and min = nearest and mip = linear */
  22978. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22979. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22980. static readonly BILINEAR_SAMPLINGMODE: number;
  22981. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22982. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22983. /** Trilinear is mag = linear and min = linear and mip = linear */
  22984. static readonly TRILINEAR_SAMPLINGMODE: number;
  22985. /** Trilinear is mag = linear and min = linear and mip = linear */
  22986. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22987. /** mag = nearest and min = nearest and mip = nearest */
  22988. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22989. /** mag = nearest and min = linear and mip = nearest */
  22990. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22991. /** mag = nearest and min = linear and mip = linear */
  22992. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22993. /** mag = nearest and min = linear and mip = none */
  22994. static readonly NEAREST_LINEAR: number;
  22995. /** mag = nearest and min = nearest and mip = none */
  22996. static readonly NEAREST_NEAREST: number;
  22997. /** mag = linear and min = nearest and mip = nearest */
  22998. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22999. /** mag = linear and min = nearest and mip = linear */
  23000. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23001. /** mag = linear and min = linear and mip = none */
  23002. static readonly LINEAR_LINEAR: number;
  23003. /** mag = linear and min = nearest and mip = none */
  23004. static readonly LINEAR_NEAREST: number;
  23005. /** Explicit coordinates mode */
  23006. static readonly EXPLICIT_MODE: number;
  23007. /** Spherical coordinates mode */
  23008. static readonly SPHERICAL_MODE: number;
  23009. /** Planar coordinates mode */
  23010. static readonly PLANAR_MODE: number;
  23011. /** Cubic coordinates mode */
  23012. static readonly CUBIC_MODE: number;
  23013. /** Projection coordinates mode */
  23014. static readonly PROJECTION_MODE: number;
  23015. /** Inverse Cubic coordinates mode */
  23016. static readonly SKYBOX_MODE: number;
  23017. /** Inverse Cubic coordinates mode */
  23018. static readonly INVCUBIC_MODE: number;
  23019. /** Equirectangular coordinates mode */
  23020. static readonly EQUIRECTANGULAR_MODE: number;
  23021. /** Equirectangular Fixed coordinates mode */
  23022. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23023. /** Equirectangular Fixed Mirrored coordinates mode */
  23024. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23025. /** Texture is not repeating outside of 0..1 UVs */
  23026. static readonly CLAMP_ADDRESSMODE: number;
  23027. /** Texture is repeating outside of 0..1 UVs */
  23028. static readonly WRAP_ADDRESSMODE: number;
  23029. /** Texture is repeating and mirrored */
  23030. static readonly MIRROR_ADDRESSMODE: number;
  23031. /**
  23032. * 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
  23033. */
  23034. static UseSerializedUrlIfAny: boolean;
  23035. /**
  23036. * Define the url of the texture.
  23037. */
  23038. url: Nullable<string>;
  23039. /**
  23040. * Define an offset on the texture to offset the u coordinates of the UVs
  23041. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23042. */
  23043. uOffset: number;
  23044. /**
  23045. * Define an offset on the texture to offset the v coordinates of the UVs
  23046. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23047. */
  23048. vOffset: number;
  23049. /**
  23050. * Define an offset on the texture to scale the u coordinates of the UVs
  23051. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23052. */
  23053. uScale: number;
  23054. /**
  23055. * Define an offset on the texture to scale the v coordinates of the UVs
  23056. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23057. */
  23058. vScale: number;
  23059. /**
  23060. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23061. * @see https://doc.babylonjs.com/how_to/more_materials
  23062. */
  23063. uAng: number;
  23064. /**
  23065. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23066. * @see https://doc.babylonjs.com/how_to/more_materials
  23067. */
  23068. vAng: number;
  23069. /**
  23070. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23071. * @see https://doc.babylonjs.com/how_to/more_materials
  23072. */
  23073. wAng: number;
  23074. /**
  23075. * Defines the center of rotation (U)
  23076. */
  23077. uRotationCenter: number;
  23078. /**
  23079. * Defines the center of rotation (V)
  23080. */
  23081. vRotationCenter: number;
  23082. /**
  23083. * Defines the center of rotation (W)
  23084. */
  23085. wRotationCenter: number;
  23086. /**
  23087. * Are mip maps generated for this texture or not.
  23088. */
  23089. get noMipmap(): boolean;
  23090. /**
  23091. * List of inspectable custom properties (used by the Inspector)
  23092. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23093. */
  23094. inspectableCustomProperties: Nullable<IInspectable[]>;
  23095. private _noMipmap;
  23096. /** @hidden */
  23097. _invertY: boolean;
  23098. private _rowGenerationMatrix;
  23099. private _cachedTextureMatrix;
  23100. private _projectionModeMatrix;
  23101. private _t0;
  23102. private _t1;
  23103. private _t2;
  23104. private _cachedUOffset;
  23105. private _cachedVOffset;
  23106. private _cachedUScale;
  23107. private _cachedVScale;
  23108. private _cachedUAng;
  23109. private _cachedVAng;
  23110. private _cachedWAng;
  23111. private _cachedProjectionMatrixId;
  23112. private _cachedCoordinatesMode;
  23113. /** @hidden */
  23114. protected _initialSamplingMode: number;
  23115. /** @hidden */
  23116. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23117. private _deleteBuffer;
  23118. protected _format: Nullable<number>;
  23119. private _delayedOnLoad;
  23120. private _delayedOnError;
  23121. private _mimeType?;
  23122. /**
  23123. * Observable triggered once the texture has been loaded.
  23124. */
  23125. onLoadObservable: Observable<Texture>;
  23126. protected _isBlocking: boolean;
  23127. /**
  23128. * Is the texture preventing material to render while loading.
  23129. * If false, a default texture will be used instead of the loading one during the preparation step.
  23130. */
  23131. set isBlocking(value: boolean);
  23132. get isBlocking(): boolean;
  23133. /**
  23134. * Get the current sampling mode associated with the texture.
  23135. */
  23136. get samplingMode(): number;
  23137. /**
  23138. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23139. */
  23140. get invertY(): boolean;
  23141. /**
  23142. * Instantiates a new texture.
  23143. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23144. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23145. * @param url defines the url of the picture to load as a texture
  23146. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23147. * @param noMipmap defines if the texture will require mip maps or not
  23148. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23149. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23150. * @param onLoad defines a callback triggered when the texture has been loaded
  23151. * @param onError defines a callback triggered when an error occurred during the loading session
  23152. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23153. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23154. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23155. * @param mimeType defines an optional mime type information
  23156. */
  23157. 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);
  23158. /**
  23159. * Update the url (and optional buffer) of this texture if url was null during construction.
  23160. * @param url the url of the texture
  23161. * @param buffer the buffer of the texture (defaults to null)
  23162. * @param onLoad callback called when the texture is loaded (defaults to null)
  23163. */
  23164. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23165. /**
  23166. * Finish the loading sequence of a texture flagged as delayed load.
  23167. * @hidden
  23168. */
  23169. delayLoad(): void;
  23170. private _prepareRowForTextureGeneration;
  23171. /**
  23172. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23173. * @returns the transform matrix of the texture.
  23174. */
  23175. getTextureMatrix(uBase?: number): Matrix;
  23176. /**
  23177. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23178. * @returns The reflection texture transform
  23179. */
  23180. getReflectionTextureMatrix(): Matrix;
  23181. /**
  23182. * Clones the texture.
  23183. * @returns the cloned texture
  23184. */
  23185. clone(): Texture;
  23186. /**
  23187. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23188. * @returns The JSON representation of the texture
  23189. */
  23190. serialize(): any;
  23191. /**
  23192. * Get the current class name of the texture useful for serialization or dynamic coding.
  23193. * @returns "Texture"
  23194. */
  23195. getClassName(): string;
  23196. /**
  23197. * Dispose the texture and release its associated resources.
  23198. */
  23199. dispose(): void;
  23200. /**
  23201. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23202. * @param parsedTexture Define the JSON representation of the texture
  23203. * @param scene Define the scene the parsed texture should be instantiated in
  23204. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23205. * @returns The parsed texture if successful
  23206. */
  23207. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23208. /**
  23209. * Creates a texture from its base 64 representation.
  23210. * @param data Define the base64 payload without the data: prefix
  23211. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23212. * @param scene Define the scene the texture should belong to
  23213. * @param noMipmap Forces the texture to not create mip map information if true
  23214. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23215. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23216. * @param onLoad define a callback triggered when the texture has been loaded
  23217. * @param onError define a callback triggered when an error occurred during the loading session
  23218. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23219. * @returns the created texture
  23220. */
  23221. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23222. /**
  23223. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23224. * @param data Define the base64 payload without the data: prefix
  23225. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23226. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23227. * @param scene Define the scene the texture should belong to
  23228. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23229. * @param noMipmap Forces the texture to not create mip map information if true
  23230. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23231. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23232. * @param onLoad define a callback triggered when the texture has been loaded
  23233. * @param onError define a callback triggered when an error occurred during the loading session
  23234. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23235. * @returns the created texture
  23236. */
  23237. 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;
  23238. }
  23239. }
  23240. declare module BABYLON {
  23241. /**
  23242. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23243. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23244. */
  23245. export class PostProcessManager {
  23246. private _scene;
  23247. private _indexBuffer;
  23248. private _vertexBuffers;
  23249. /**
  23250. * Creates a new instance PostProcess
  23251. * @param scene The scene that the post process is associated with.
  23252. */
  23253. constructor(scene: Scene);
  23254. private _prepareBuffers;
  23255. private _buildIndexBuffer;
  23256. /**
  23257. * Rebuilds the vertex buffers of the manager.
  23258. * @hidden
  23259. */
  23260. _rebuild(): void;
  23261. /**
  23262. * Prepares a frame to be run through a post process.
  23263. * @param sourceTexture The input texture to the post procesess. (default: null)
  23264. * @param postProcesses An array of post processes to be run. (default: null)
  23265. * @returns True if the post processes were able to be run.
  23266. * @hidden
  23267. */
  23268. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23269. /**
  23270. * Manually render a set of post processes to a texture.
  23271. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23272. * @param postProcesses An array of post processes to be run.
  23273. * @param targetTexture The target texture to render to.
  23274. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23275. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23276. * @param lodLevel defines which lod of the texture to render to
  23277. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23278. */
  23279. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23280. /**
  23281. * Finalize the result of the output of the postprocesses.
  23282. * @param doNotPresent If true the result will not be displayed to the screen.
  23283. * @param targetTexture The target texture to render to.
  23284. * @param faceIndex The index of the face to bind the target texture to.
  23285. * @param postProcesses The array of post processes to render.
  23286. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23287. * @hidden
  23288. */
  23289. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23290. /**
  23291. * Disposes of the post process manager.
  23292. */
  23293. dispose(): void;
  23294. }
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * This Helps creating a texture that will be created from a camera in your scene.
  23299. * It is basically a dynamic texture that could be used to create special effects for instance.
  23300. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23301. */
  23302. export class RenderTargetTexture extends Texture {
  23303. isCube: boolean;
  23304. /**
  23305. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23306. */
  23307. static readonly REFRESHRATE_RENDER_ONCE: number;
  23308. /**
  23309. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23310. */
  23311. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23312. /**
  23313. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23314. * the central point of your effect and can save a lot of performances.
  23315. */
  23316. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23317. /**
  23318. * Use this predicate to dynamically define the list of mesh you want to render.
  23319. * If set, the renderList property will be overwritten.
  23320. */
  23321. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23322. private _renderList;
  23323. /**
  23324. * Use this list to define the list of mesh you want to render.
  23325. */
  23326. get renderList(): Nullable<Array<AbstractMesh>>;
  23327. set renderList(value: Nullable<Array<AbstractMesh>>);
  23328. /**
  23329. * Use this function to overload the renderList array at rendering time.
  23330. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23331. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23332. * the cube (if the RTT is a cube, else layerOrFace=0).
  23333. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23334. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23335. * hold dummy elements!
  23336. */
  23337. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23338. private _hookArray;
  23339. /**
  23340. * Define if particles should be rendered in your texture.
  23341. */
  23342. renderParticles: boolean;
  23343. /**
  23344. * Define if sprites should be rendered in your texture.
  23345. */
  23346. renderSprites: boolean;
  23347. /**
  23348. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23349. */
  23350. coordinatesMode: number;
  23351. /**
  23352. * Define the camera used to render the texture.
  23353. */
  23354. activeCamera: Nullable<Camera>;
  23355. /**
  23356. * Override the mesh isReady function with your own one.
  23357. */
  23358. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23359. /**
  23360. * Override the render function of the texture with your own one.
  23361. */
  23362. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23363. /**
  23364. * Define if camera post processes should be use while rendering the texture.
  23365. */
  23366. useCameraPostProcesses: boolean;
  23367. /**
  23368. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23369. */
  23370. ignoreCameraViewport: boolean;
  23371. private _postProcessManager;
  23372. private _postProcesses;
  23373. private _resizeObserver;
  23374. /**
  23375. * An event triggered when the texture is unbind.
  23376. */
  23377. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23378. /**
  23379. * An event triggered when the texture is unbind.
  23380. */
  23381. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23382. private _onAfterUnbindObserver;
  23383. /**
  23384. * Set a after unbind callback in the texture.
  23385. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23386. */
  23387. set onAfterUnbind(callback: () => void);
  23388. /**
  23389. * An event triggered before rendering the texture
  23390. */
  23391. onBeforeRenderObservable: Observable<number>;
  23392. private _onBeforeRenderObserver;
  23393. /**
  23394. * Set a before render callback in the texture.
  23395. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23396. */
  23397. set onBeforeRender(callback: (faceIndex: number) => void);
  23398. /**
  23399. * An event triggered after rendering the texture
  23400. */
  23401. onAfterRenderObservable: Observable<number>;
  23402. private _onAfterRenderObserver;
  23403. /**
  23404. * Set a after render callback in the texture.
  23405. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23406. */
  23407. set onAfterRender(callback: (faceIndex: number) => void);
  23408. /**
  23409. * An event triggered after the texture clear
  23410. */
  23411. onClearObservable: Observable<Engine>;
  23412. private _onClearObserver;
  23413. /**
  23414. * Set a clear callback in the texture.
  23415. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23416. */
  23417. set onClear(callback: (Engine: Engine) => void);
  23418. /**
  23419. * An event triggered when the texture is resized.
  23420. */
  23421. onResizeObservable: Observable<RenderTargetTexture>;
  23422. /**
  23423. * Define the clear color of the Render Target if it should be different from the scene.
  23424. */
  23425. clearColor: Color4;
  23426. protected _size: number | {
  23427. width: number;
  23428. height: number;
  23429. layers?: number;
  23430. };
  23431. protected _initialSizeParameter: number | {
  23432. width: number;
  23433. height: number;
  23434. } | {
  23435. ratio: number;
  23436. };
  23437. protected _sizeRatio: Nullable<number>;
  23438. /** @hidden */
  23439. _generateMipMaps: boolean;
  23440. protected _renderingManager: RenderingManager;
  23441. /** @hidden */
  23442. _waitingRenderList: string[];
  23443. protected _doNotChangeAspectRatio: boolean;
  23444. protected _currentRefreshId: number;
  23445. protected _refreshRate: number;
  23446. protected _textureMatrix: Matrix;
  23447. protected _samples: number;
  23448. protected _renderTargetOptions: RenderTargetCreationOptions;
  23449. /**
  23450. * Gets render target creation options that were used.
  23451. */
  23452. get renderTargetOptions(): RenderTargetCreationOptions;
  23453. protected _onRatioRescale(): void;
  23454. /**
  23455. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23456. * It must define where the camera used to render the texture is set
  23457. */
  23458. boundingBoxPosition: Vector3;
  23459. private _boundingBoxSize;
  23460. /**
  23461. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23462. * When defined, the cubemap will switch to local mode
  23463. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23464. * @example https://www.babylonjs-playground.com/#RNASML
  23465. */
  23466. set boundingBoxSize(value: Vector3);
  23467. get boundingBoxSize(): Vector3;
  23468. /**
  23469. * In case the RTT has been created with a depth texture, get the associated
  23470. * depth texture.
  23471. * Otherwise, return null.
  23472. */
  23473. get depthStencilTexture(): Nullable<InternalTexture>;
  23474. /**
  23475. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23476. * or used a shadow, depth texture...
  23477. * @param name The friendly name of the texture
  23478. * @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)
  23479. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23480. * @param generateMipMaps True if mip maps need to be generated after render.
  23481. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23482. * @param type The type of the buffer in the RTT (int, half float, float...)
  23483. * @param isCube True if a cube texture needs to be created
  23484. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23485. * @param generateDepthBuffer True to generate a depth buffer
  23486. * @param generateStencilBuffer True to generate a stencil buffer
  23487. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23488. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23489. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23490. */
  23491. constructor(name: string, size: number | {
  23492. width: number;
  23493. height: number;
  23494. layers?: number;
  23495. } | {
  23496. ratio: number;
  23497. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23498. /**
  23499. * Creates a depth stencil texture.
  23500. * This is only available in WebGL 2 or with the depth texture extension available.
  23501. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23502. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23503. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23504. */
  23505. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23506. private _processSizeParameter;
  23507. /**
  23508. * Define the number of samples to use in case of MSAA.
  23509. * It defaults to one meaning no MSAA has been enabled.
  23510. */
  23511. get samples(): number;
  23512. set samples(value: number);
  23513. /**
  23514. * Resets the refresh counter of the texture and start bak from scratch.
  23515. * Could be useful to regenerate the texture if it is setup to render only once.
  23516. */
  23517. resetRefreshCounter(): void;
  23518. /**
  23519. * Define the refresh rate of the texture or the rendering frequency.
  23520. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23521. */
  23522. get refreshRate(): number;
  23523. set refreshRate(value: number);
  23524. /**
  23525. * Adds a post process to the render target rendering passes.
  23526. * @param postProcess define the post process to add
  23527. */
  23528. addPostProcess(postProcess: PostProcess): void;
  23529. /**
  23530. * Clear all the post processes attached to the render target
  23531. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23532. */
  23533. clearPostProcesses(dispose?: boolean): void;
  23534. /**
  23535. * Remove one of the post process from the list of attached post processes to the texture
  23536. * @param postProcess define the post process to remove from the list
  23537. */
  23538. removePostProcess(postProcess: PostProcess): void;
  23539. /** @hidden */
  23540. _shouldRender(): boolean;
  23541. /**
  23542. * Gets the actual render size of the texture.
  23543. * @returns the width of the render size
  23544. */
  23545. getRenderSize(): number;
  23546. /**
  23547. * Gets the actual render width of the texture.
  23548. * @returns the width of the render size
  23549. */
  23550. getRenderWidth(): number;
  23551. /**
  23552. * Gets the actual render height of the texture.
  23553. * @returns the height of the render size
  23554. */
  23555. getRenderHeight(): number;
  23556. /**
  23557. * Gets the actual number of layers of the texture.
  23558. * @returns the number of layers
  23559. */
  23560. getRenderLayers(): number;
  23561. /**
  23562. * Get if the texture can be rescaled or not.
  23563. */
  23564. get canRescale(): boolean;
  23565. /**
  23566. * Resize the texture using a ratio.
  23567. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23568. */
  23569. scale(ratio: number): void;
  23570. /**
  23571. * Get the texture reflection matrix used to rotate/transform the reflection.
  23572. * @returns the reflection matrix
  23573. */
  23574. getReflectionTextureMatrix(): Matrix;
  23575. /**
  23576. * Resize the texture to a new desired size.
  23577. * Be carrefull as it will recreate all the data in the new texture.
  23578. * @param size Define the new size. It can be:
  23579. * - a number for squared texture,
  23580. * - an object containing { width: number, height: number }
  23581. * - or an object containing a ratio { ratio: number }
  23582. */
  23583. resize(size: number | {
  23584. width: number;
  23585. height: number;
  23586. } | {
  23587. ratio: number;
  23588. }): void;
  23589. private _defaultRenderListPrepared;
  23590. /**
  23591. * Renders all the objects from the render list into the texture.
  23592. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23593. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23594. */
  23595. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23596. private _bestReflectionRenderTargetDimension;
  23597. private _prepareRenderingManager;
  23598. /**
  23599. * @hidden
  23600. * @param faceIndex face index to bind to if this is a cubetexture
  23601. * @param layer defines the index of the texture to bind in the array
  23602. */
  23603. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23604. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23605. private renderToTarget;
  23606. /**
  23607. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23608. * This allowed control for front to back rendering or reversly depending of the special needs.
  23609. *
  23610. * @param renderingGroupId The rendering group id corresponding to its index
  23611. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23612. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23613. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23614. */
  23615. 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;
  23616. /**
  23617. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23618. *
  23619. * @param renderingGroupId The rendering group id corresponding to its index
  23620. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23621. */
  23622. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23623. /**
  23624. * Clones the texture.
  23625. * @returns the cloned texture
  23626. */
  23627. clone(): RenderTargetTexture;
  23628. /**
  23629. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23630. * @returns The JSON representation of the texture
  23631. */
  23632. serialize(): any;
  23633. /**
  23634. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23635. */
  23636. disposeFramebufferObjects(): void;
  23637. /**
  23638. * Dispose the texture and release its associated resources.
  23639. */
  23640. dispose(): void;
  23641. /** @hidden */
  23642. _rebuild(): void;
  23643. /**
  23644. * Clear the info related to rendering groups preventing retention point in material dispose.
  23645. */
  23646. freeRenderingGroups(): void;
  23647. /**
  23648. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23649. * @returns the view count
  23650. */
  23651. getViewCount(): number;
  23652. }
  23653. }
  23654. declare module BABYLON {
  23655. /**
  23656. * Class used to manipulate GUIDs
  23657. */
  23658. export class GUID {
  23659. /**
  23660. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23661. * Be aware Math.random() could cause collisions, but:
  23662. * "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"
  23663. * @returns a pseudo random id
  23664. */
  23665. static RandomId(): string;
  23666. }
  23667. }
  23668. declare module BABYLON {
  23669. /**
  23670. * Options to be used when creating a shadow depth material
  23671. */
  23672. export interface IIOptionShadowDepthMaterial {
  23673. /** Variables in the vertex shader code that need to have their names remapped.
  23674. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23675. * "var_name" should be either: worldPos or vNormalW
  23676. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23677. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23678. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23679. */
  23680. remappedVariables?: string[];
  23681. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23682. standalone?: boolean;
  23683. }
  23684. /**
  23685. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23686. */
  23687. export class ShadowDepthWrapper {
  23688. private _scene;
  23689. private _options?;
  23690. private _baseMaterial;
  23691. private _onEffectCreatedObserver;
  23692. private _subMeshToEffect;
  23693. private _subMeshToDepthEffect;
  23694. private _meshes;
  23695. /** @hidden */
  23696. _matriceNames: any;
  23697. /** Gets the standalone status of the wrapper */
  23698. get standalone(): boolean;
  23699. /** Gets the base material the wrapper is built upon */
  23700. get baseMaterial(): Material;
  23701. /**
  23702. * Instantiate a new shadow depth wrapper.
  23703. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23704. * generate the shadow depth map. For more information, please refer to the documentation:
  23705. * https://doc.babylonjs.com/babylon101/shadows
  23706. * @param baseMaterial Material to wrap
  23707. * @param scene Define the scene the material belongs to
  23708. * @param options Options used to create the wrapper
  23709. */
  23710. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23711. /**
  23712. * Gets the effect to use to generate the depth map
  23713. * @param subMesh subMesh to get the effect for
  23714. * @param shadowGenerator shadow generator to get the effect for
  23715. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23716. */
  23717. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23718. /**
  23719. * Specifies that the submesh is ready to be used for depth rendering
  23720. * @param subMesh submesh to check
  23721. * @param defines the list of defines to take into account when checking the effect
  23722. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23723. * @param useInstances specifies that instances should be used
  23724. * @returns a boolean indicating that the submesh is ready or not
  23725. */
  23726. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23727. /**
  23728. * Disposes the resources
  23729. */
  23730. dispose(): void;
  23731. private _makeEffect;
  23732. }
  23733. }
  23734. declare module BABYLON {
  23735. interface ThinEngine {
  23736. /**
  23737. * Unbind a list of render target textures from the webGL context
  23738. * This is used only when drawBuffer extension or webGL2 are active
  23739. * @param textures defines the render target textures to unbind
  23740. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23741. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23742. */
  23743. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23744. /**
  23745. * Create a multi render target texture
  23746. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23747. * @param size defines the size of the texture
  23748. * @param options defines the creation options
  23749. * @returns the cube texture as an InternalTexture
  23750. */
  23751. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23752. /**
  23753. * Update the sample count for a given multiple render target texture
  23754. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23755. * @param textures defines the textures to update
  23756. * @param samples defines the sample count to set
  23757. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23758. */
  23759. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23760. /**
  23761. * Select a subsets of attachments to draw to.
  23762. * @param attachments gl attachments
  23763. */
  23764. bindAttachments(attachments: number[]): void;
  23765. }
  23766. }
  23767. declare module BABYLON {
  23768. /**
  23769. * Creation options of the multi render target texture.
  23770. */
  23771. export interface IMultiRenderTargetOptions {
  23772. /**
  23773. * Define if the texture needs to create mip maps after render.
  23774. */
  23775. generateMipMaps?: boolean;
  23776. /**
  23777. * Define the types of all the draw buffers we want to create
  23778. */
  23779. types?: number[];
  23780. /**
  23781. * Define the sampling modes of all the draw buffers we want to create
  23782. */
  23783. samplingModes?: number[];
  23784. /**
  23785. * Define if a depth buffer is required
  23786. */
  23787. generateDepthBuffer?: boolean;
  23788. /**
  23789. * Define if a stencil buffer is required
  23790. */
  23791. generateStencilBuffer?: boolean;
  23792. /**
  23793. * Define if a depth texture is required instead of a depth buffer
  23794. */
  23795. generateDepthTexture?: boolean;
  23796. /**
  23797. * Define the number of desired draw buffers
  23798. */
  23799. textureCount?: number;
  23800. /**
  23801. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23802. */
  23803. doNotChangeAspectRatio?: boolean;
  23804. /**
  23805. * Define the default type of the buffers we are creating
  23806. */
  23807. defaultType?: number;
  23808. }
  23809. /**
  23810. * A multi render target, like a render target provides the ability to render to a texture.
  23811. * Unlike the render target, it can render to several draw buffers in one draw.
  23812. * This is specially interesting in deferred rendering or for any effects requiring more than
  23813. * just one color from a single pass.
  23814. */
  23815. export class MultiRenderTarget extends RenderTargetTexture {
  23816. private _internalTextures;
  23817. private _textures;
  23818. private _multiRenderTargetOptions;
  23819. private _count;
  23820. /**
  23821. * Get if draw buffers are currently supported by the used hardware and browser.
  23822. */
  23823. get isSupported(): boolean;
  23824. /**
  23825. * Get the list of textures generated by the multi render target.
  23826. */
  23827. get textures(): Texture[];
  23828. /**
  23829. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23830. */
  23831. get count(): number;
  23832. /**
  23833. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23834. */
  23835. get depthTexture(): Texture;
  23836. /**
  23837. * Set the wrapping mode on U of all the textures we are rendering to.
  23838. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23839. */
  23840. set wrapU(wrap: number);
  23841. /**
  23842. * Set the wrapping mode on V of all the textures we are rendering to.
  23843. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23844. */
  23845. set wrapV(wrap: number);
  23846. /**
  23847. * Instantiate a new multi render target texture.
  23848. * A multi render target, like a render target provides the ability to render to a texture.
  23849. * Unlike the render target, it can render to several draw buffers in one draw.
  23850. * This is specially interesting in deferred rendering or for any effects requiring more than
  23851. * just one color from a single pass.
  23852. * @param name Define the name of the texture
  23853. * @param size Define the size of the buffers to render to
  23854. * @param count Define the number of target we are rendering into
  23855. * @param scene Define the scene the texture belongs to
  23856. * @param options Define the options used to create the multi render target
  23857. */
  23858. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23859. /** @hidden */
  23860. _rebuild(): void;
  23861. private _createInternalTextures;
  23862. private _createTextures;
  23863. /**
  23864. * Define the number of samples used if MSAA is enabled.
  23865. */
  23866. get samples(): number;
  23867. set samples(value: number);
  23868. /**
  23869. * Resize all the textures in the multi render target.
  23870. * Be carrefull as it will recreate all the data in the new texture.
  23871. * @param size Define the new size
  23872. */
  23873. resize(size: any): void;
  23874. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23875. /**
  23876. * Dispose the render targets and their associated resources
  23877. */
  23878. dispose(): void;
  23879. /**
  23880. * Release all the underlying texture used as draw buffers.
  23881. */
  23882. releaseInternalTextures(): void;
  23883. }
  23884. }
  23885. declare module BABYLON {
  23886. /** @hidden */
  23887. export var imageProcessingPixelShader: {
  23888. name: string;
  23889. shader: string;
  23890. };
  23891. }
  23892. declare module BABYLON {
  23893. /**
  23894. * ImageProcessingPostProcess
  23895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23896. */
  23897. export class ImageProcessingPostProcess extends PostProcess {
  23898. /**
  23899. * Default configuration related to image processing available in the PBR Material.
  23900. */
  23901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23902. /**
  23903. * Gets the image processing configuration used either in this material.
  23904. */
  23905. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23906. /**
  23907. * Sets the Default image processing configuration used either in the this material.
  23908. *
  23909. * If sets to null, the scene one is in use.
  23910. */
  23911. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23912. /**
  23913. * Keep track of the image processing observer to allow dispose and replace.
  23914. */
  23915. private _imageProcessingObserver;
  23916. /**
  23917. * Attaches a new image processing configuration to the PBR Material.
  23918. * @param configuration
  23919. */
  23920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23921. /**
  23922. * If the post process is supported.
  23923. */
  23924. get isSupported(): boolean;
  23925. /**
  23926. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23927. */
  23928. get colorCurves(): Nullable<ColorCurves>;
  23929. /**
  23930. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23931. */
  23932. set colorCurves(value: Nullable<ColorCurves>);
  23933. /**
  23934. * Gets wether the color curves effect is enabled.
  23935. */
  23936. get colorCurvesEnabled(): boolean;
  23937. /**
  23938. * Sets wether the color curves effect is enabled.
  23939. */
  23940. set colorCurvesEnabled(value: boolean);
  23941. /**
  23942. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23943. */
  23944. get colorGradingTexture(): Nullable<BaseTexture>;
  23945. /**
  23946. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23947. */
  23948. set colorGradingTexture(value: Nullable<BaseTexture>);
  23949. /**
  23950. * Gets wether the color grading effect is enabled.
  23951. */
  23952. get colorGradingEnabled(): boolean;
  23953. /**
  23954. * Gets wether the color grading effect is enabled.
  23955. */
  23956. set colorGradingEnabled(value: boolean);
  23957. /**
  23958. * Gets exposure used in the effect.
  23959. */
  23960. get exposure(): number;
  23961. /**
  23962. * Sets exposure used in the effect.
  23963. */
  23964. set exposure(value: number);
  23965. /**
  23966. * Gets wether tonemapping is enabled or not.
  23967. */
  23968. get toneMappingEnabled(): boolean;
  23969. /**
  23970. * Sets wether tonemapping is enabled or not
  23971. */
  23972. set toneMappingEnabled(value: boolean);
  23973. /**
  23974. * Gets the type of tone mapping effect.
  23975. */
  23976. get toneMappingType(): number;
  23977. /**
  23978. * Sets the type of tone mapping effect.
  23979. */
  23980. set toneMappingType(value: number);
  23981. /**
  23982. * Gets contrast used in the effect.
  23983. */
  23984. get contrast(): number;
  23985. /**
  23986. * Sets contrast used in the effect.
  23987. */
  23988. set contrast(value: number);
  23989. /**
  23990. * Gets Vignette stretch size.
  23991. */
  23992. get vignetteStretch(): number;
  23993. /**
  23994. * Sets Vignette stretch size.
  23995. */
  23996. set vignetteStretch(value: number);
  23997. /**
  23998. * Gets Vignette centre X Offset.
  23999. */
  24000. get vignetteCentreX(): number;
  24001. /**
  24002. * Sets Vignette centre X Offset.
  24003. */
  24004. set vignetteCentreX(value: number);
  24005. /**
  24006. * Gets Vignette centre Y Offset.
  24007. */
  24008. get vignetteCentreY(): number;
  24009. /**
  24010. * Sets Vignette centre Y Offset.
  24011. */
  24012. set vignetteCentreY(value: number);
  24013. /**
  24014. * Gets Vignette weight or intensity of the vignette effect.
  24015. */
  24016. get vignetteWeight(): number;
  24017. /**
  24018. * Sets Vignette weight or intensity of the vignette effect.
  24019. */
  24020. set vignetteWeight(value: number);
  24021. /**
  24022. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24023. * if vignetteEnabled is set to true.
  24024. */
  24025. get vignetteColor(): Color4;
  24026. /**
  24027. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24028. * if vignetteEnabled is set to true.
  24029. */
  24030. set vignetteColor(value: Color4);
  24031. /**
  24032. * Gets Camera field of view used by the Vignette effect.
  24033. */
  24034. get vignetteCameraFov(): number;
  24035. /**
  24036. * Sets Camera field of view used by the Vignette effect.
  24037. */
  24038. set vignetteCameraFov(value: number);
  24039. /**
  24040. * Gets the vignette blend mode allowing different kind of effect.
  24041. */
  24042. get vignetteBlendMode(): number;
  24043. /**
  24044. * Sets the vignette blend mode allowing different kind of effect.
  24045. */
  24046. set vignetteBlendMode(value: number);
  24047. /**
  24048. * Gets wether the vignette effect is enabled.
  24049. */
  24050. get vignetteEnabled(): boolean;
  24051. /**
  24052. * Sets wether the vignette effect is enabled.
  24053. */
  24054. set vignetteEnabled(value: boolean);
  24055. private _fromLinearSpace;
  24056. /**
  24057. * Gets wether the input of the processing is in Gamma or Linear Space.
  24058. */
  24059. get fromLinearSpace(): boolean;
  24060. /**
  24061. * Sets wether the input of the processing is in Gamma or Linear Space.
  24062. */
  24063. set fromLinearSpace(value: boolean);
  24064. /**
  24065. * Defines cache preventing GC.
  24066. */
  24067. private _defines;
  24068. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24069. /**
  24070. * "ImageProcessingPostProcess"
  24071. * @returns "ImageProcessingPostProcess"
  24072. */
  24073. getClassName(): string;
  24074. /**
  24075. * @hidden
  24076. */
  24077. _updateParameters(): void;
  24078. dispose(camera?: Camera): void;
  24079. }
  24080. }
  24081. declare module BABYLON {
  24082. /** @hidden */
  24083. export var fibonacci: {
  24084. name: string;
  24085. shader: string;
  24086. };
  24087. }
  24088. declare module BABYLON {
  24089. /** @hidden */
  24090. export var subSurfaceScatteringFunctions: {
  24091. name: string;
  24092. shader: string;
  24093. };
  24094. }
  24095. declare module BABYLON {
  24096. /** @hidden */
  24097. export var diffusionProfile: {
  24098. name: string;
  24099. shader: string;
  24100. };
  24101. }
  24102. declare module BABYLON {
  24103. /** @hidden */
  24104. export var subSurfaceScatteringPixelShader: {
  24105. name: string;
  24106. shader: string;
  24107. };
  24108. }
  24109. declare module BABYLON {
  24110. /**
  24111. * Sub surface scattering post process
  24112. */
  24113. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24114. /** @hidden */
  24115. texelWidth: number;
  24116. /** @hidden */
  24117. texelHeight: number;
  24118. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24119. }
  24120. }
  24121. declare module BABYLON {
  24122. /**
  24123. * Interface for defining prepass effects in the prepass post-process pipeline
  24124. */
  24125. export interface PrePassEffectConfiguration {
  24126. /**
  24127. * Post process to attach for this effect
  24128. */
  24129. postProcess: PostProcess;
  24130. /**
  24131. * Is the effect enabled
  24132. */
  24133. enabled: boolean;
  24134. /**
  24135. * Disposes the effect configuration
  24136. */
  24137. dispose(): void;
  24138. /**
  24139. * Disposes the effect configuration
  24140. */
  24141. createPostProcess: () => PostProcess;
  24142. }
  24143. }
  24144. declare module BABYLON {
  24145. /**
  24146. * Contains all parameters needed for the prepass to perform
  24147. * screen space subsurface scattering
  24148. */
  24149. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24150. private _ssDiffusionS;
  24151. private _ssFilterRadii;
  24152. private _ssDiffusionD;
  24153. /**
  24154. * Post process to attach for screen space subsurface scattering
  24155. */
  24156. postProcess: SubSurfaceScatteringPostProcess;
  24157. /**
  24158. * Diffusion profile color for subsurface scattering
  24159. */
  24160. get ssDiffusionS(): number[];
  24161. /**
  24162. * Diffusion profile max color channel value for subsurface scattering
  24163. */
  24164. get ssDiffusionD(): number[];
  24165. /**
  24166. * Diffusion profile filter radius for subsurface scattering
  24167. */
  24168. get ssFilterRadii(): number[];
  24169. /**
  24170. * Is subsurface enabled
  24171. */
  24172. enabled: boolean;
  24173. /**
  24174. * Diffusion profile colors for subsurface scattering
  24175. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24176. * See ...
  24177. * Note that you can only store up to 5 of them
  24178. */
  24179. ssDiffusionProfileColors: Color3[];
  24180. /**
  24181. * Defines the ratio real world => scene units.
  24182. * Used for subsurface scattering
  24183. */
  24184. metersPerUnit: number;
  24185. private _scene;
  24186. /**
  24187. * Builds a subsurface configuration object
  24188. * @param scene The scene
  24189. */
  24190. constructor(scene: Scene);
  24191. /**
  24192. * Adds a new diffusion profile.
  24193. * Useful for more realistic subsurface scattering on diverse materials.
  24194. * @param color The color of the diffusion profile. Should be the average color of the material.
  24195. * @return The index of the diffusion profile for the material subsurface configuration
  24196. */
  24197. addDiffusionProfile(color: Color3): number;
  24198. /**
  24199. * Creates the sss post process
  24200. * @return The created post process
  24201. */
  24202. createPostProcess(): SubSurfaceScatteringPostProcess;
  24203. /**
  24204. * Deletes all diffusion profiles.
  24205. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24206. */
  24207. clearAllDiffusionProfiles(): void;
  24208. /**
  24209. * Disposes this object
  24210. */
  24211. dispose(): void;
  24212. /**
  24213. * @hidden
  24214. * https://zero-radiance.github.io/post/sampling-diffusion/
  24215. *
  24216. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24217. * ------------------------------------------------------------------------------------
  24218. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24219. * PDF[r, phi, s] = r * R[r, phi, s]
  24220. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24221. * ------------------------------------------------------------------------------------
  24222. * We importance sample the color channel with the widest scattering distance.
  24223. */
  24224. getDiffusionProfileParameters(color: Color3): number;
  24225. /**
  24226. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24227. * 'u' is the random number (the value of the CDF): [0, 1).
  24228. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24229. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24230. */
  24231. private _sampleBurleyDiffusionProfile;
  24232. }
  24233. }
  24234. declare module BABYLON {
  24235. /**
  24236. * Renders a pre pass of the scene
  24237. * This means every mesh in the scene will be rendered to a render target texture
  24238. * And then this texture will be composited to the rendering canvas with post processes
  24239. * It is necessary for effects like subsurface scattering or deferred shading
  24240. */
  24241. export class PrePassRenderer {
  24242. /** @hidden */
  24243. static _SceneComponentInitialization: (scene: Scene) => void;
  24244. private _scene;
  24245. private _engine;
  24246. private _isDirty;
  24247. /**
  24248. * Number of textures in the multi render target texture where the scene is directly rendered
  24249. */
  24250. readonly mrtCount: number;
  24251. /**
  24252. * The render target where the scene is directly rendered
  24253. */
  24254. prePassRT: MultiRenderTarget;
  24255. private _mrtTypes;
  24256. private _multiRenderAttachments;
  24257. private _defaultAttachments;
  24258. private _clearAttachments;
  24259. private _postProcesses;
  24260. private readonly _clearColor;
  24261. /**
  24262. * Image processing post process for composition
  24263. */
  24264. imageProcessingPostProcess: ImageProcessingPostProcess;
  24265. /**
  24266. * Configuration for sub surface scattering post process
  24267. */
  24268. subSurfaceConfiguration: SubSurfaceConfiguration;
  24269. /**
  24270. * Should materials render their geometry on the MRT
  24271. */
  24272. materialsShouldRenderGeometry: boolean;
  24273. /**
  24274. * Should materials render the irradiance information on the MRT
  24275. */
  24276. materialsShouldRenderIrradiance: boolean;
  24277. private _enabled;
  24278. /**
  24279. * Indicates if the prepass is enabled
  24280. */
  24281. get enabled(): boolean;
  24282. /**
  24283. * How many samples are used for MSAA of the scene render target
  24284. */
  24285. get samples(): number;
  24286. set samples(n: number);
  24287. /**
  24288. * Instanciates a prepass renderer
  24289. * @param scene The scene
  24290. */
  24291. constructor(scene: Scene);
  24292. private _initializeAttachments;
  24293. private _createCompositionEffect;
  24294. /**
  24295. * Indicates if rendering a prepass is supported
  24296. */
  24297. get isSupported(): boolean;
  24298. /**
  24299. * Sets the proper output textures to draw in the engine.
  24300. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24301. */
  24302. bindAttachmentsForEffect(effect: Effect): void;
  24303. /**
  24304. * @hidden
  24305. */
  24306. _beforeCameraDraw(): void;
  24307. /**
  24308. * @hidden
  24309. */
  24310. _afterCameraDraw(): void;
  24311. private _checkRTSize;
  24312. private _bindFrameBuffer;
  24313. /**
  24314. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24315. */
  24316. clear(): void;
  24317. private _setState;
  24318. private _enable;
  24319. private _disable;
  24320. private _resetPostProcessChain;
  24321. private _bindPostProcessChain;
  24322. /**
  24323. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24324. */
  24325. markAsDirty(): void;
  24326. private _update;
  24327. /**
  24328. * Disposes the prepass renderer.
  24329. */
  24330. dispose(): void;
  24331. }
  24332. }
  24333. declare module BABYLON {
  24334. /**
  24335. * Options for compiling materials.
  24336. */
  24337. export interface IMaterialCompilationOptions {
  24338. /**
  24339. * Defines whether clip planes are enabled.
  24340. */
  24341. clipPlane: boolean;
  24342. /**
  24343. * Defines whether instances are enabled.
  24344. */
  24345. useInstances: boolean;
  24346. }
  24347. /**
  24348. * Options passed when calling customShaderNameResolve
  24349. */
  24350. export interface ICustomShaderNameResolveOptions {
  24351. /**
  24352. * 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
  24353. */
  24354. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24355. }
  24356. /**
  24357. * Base class for the main features of a material in Babylon.js
  24358. */
  24359. export class Material implements IAnimatable {
  24360. /**
  24361. * Returns the triangle fill mode
  24362. */
  24363. static readonly TriangleFillMode: number;
  24364. /**
  24365. * Returns the wireframe mode
  24366. */
  24367. static readonly WireFrameFillMode: number;
  24368. /**
  24369. * Returns the point fill mode
  24370. */
  24371. static readonly PointFillMode: number;
  24372. /**
  24373. * Returns the point list draw mode
  24374. */
  24375. static readonly PointListDrawMode: number;
  24376. /**
  24377. * Returns the line list draw mode
  24378. */
  24379. static readonly LineListDrawMode: number;
  24380. /**
  24381. * Returns the line loop draw mode
  24382. */
  24383. static readonly LineLoopDrawMode: number;
  24384. /**
  24385. * Returns the line strip draw mode
  24386. */
  24387. static readonly LineStripDrawMode: number;
  24388. /**
  24389. * Returns the triangle strip draw mode
  24390. */
  24391. static readonly TriangleStripDrawMode: number;
  24392. /**
  24393. * Returns the triangle fan draw mode
  24394. */
  24395. static readonly TriangleFanDrawMode: number;
  24396. /**
  24397. * Stores the clock-wise side orientation
  24398. */
  24399. static readonly ClockWiseSideOrientation: number;
  24400. /**
  24401. * Stores the counter clock-wise side orientation
  24402. */
  24403. static readonly CounterClockWiseSideOrientation: number;
  24404. /**
  24405. * The dirty texture flag value
  24406. */
  24407. static readonly TextureDirtyFlag: number;
  24408. /**
  24409. * The dirty light flag value
  24410. */
  24411. static readonly LightDirtyFlag: number;
  24412. /**
  24413. * The dirty fresnel flag value
  24414. */
  24415. static readonly FresnelDirtyFlag: number;
  24416. /**
  24417. * The dirty attribute flag value
  24418. */
  24419. static readonly AttributesDirtyFlag: number;
  24420. /**
  24421. * The dirty misc flag value
  24422. */
  24423. static readonly MiscDirtyFlag: number;
  24424. /**
  24425. * The all dirty flag value
  24426. */
  24427. static readonly AllDirtyFlag: number;
  24428. /**
  24429. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24430. */
  24431. static readonly MATERIAL_OPAQUE: number;
  24432. /**
  24433. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24434. */
  24435. static readonly MATERIAL_ALPHATEST: number;
  24436. /**
  24437. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24438. */
  24439. static readonly MATERIAL_ALPHABLEND: number;
  24440. /**
  24441. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24442. * They are also discarded below the alpha cutoff threshold to improve performances.
  24443. */
  24444. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24445. /**
  24446. * The Whiteout method is used to blend normals.
  24447. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24448. */
  24449. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24450. /**
  24451. * The Reoriented Normal Mapping method is used to blend normals.
  24452. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24453. */
  24454. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24455. /**
  24456. * Custom callback helping to override the default shader used in the material.
  24457. */
  24458. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24459. /**
  24460. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24461. */
  24462. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24463. /**
  24464. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24465. * This means that the material can keep using a previous shader while a new one is being compiled.
  24466. * This is mostly used when shader parallel compilation is supported (true by default)
  24467. */
  24468. allowShaderHotSwapping: boolean;
  24469. /**
  24470. * The ID of the material
  24471. */
  24472. id: string;
  24473. /**
  24474. * Gets or sets the unique id of the material
  24475. */
  24476. uniqueId: number;
  24477. /**
  24478. * The name of the material
  24479. */
  24480. name: string;
  24481. /**
  24482. * Gets or sets user defined metadata
  24483. */
  24484. metadata: any;
  24485. /**
  24486. * For internal use only. Please do not use.
  24487. */
  24488. reservedDataStore: any;
  24489. /**
  24490. * Specifies if the ready state should be checked on each call
  24491. */
  24492. checkReadyOnEveryCall: boolean;
  24493. /**
  24494. * Specifies if the ready state should be checked once
  24495. */
  24496. checkReadyOnlyOnce: boolean;
  24497. /**
  24498. * The state of the material
  24499. */
  24500. state: string;
  24501. /**
  24502. * If the material can be rendered to several textures with MRT extension
  24503. */
  24504. get canRenderToMRT(): boolean;
  24505. /**
  24506. * The alpha value of the material
  24507. */
  24508. protected _alpha: number;
  24509. /**
  24510. * List of inspectable custom properties (used by the Inspector)
  24511. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24512. */
  24513. inspectableCustomProperties: IInspectable[];
  24514. /**
  24515. * Sets the alpha value of the material
  24516. */
  24517. set alpha(value: number);
  24518. /**
  24519. * Gets the alpha value of the material
  24520. */
  24521. get alpha(): number;
  24522. /**
  24523. * Specifies if back face culling is enabled
  24524. */
  24525. protected _backFaceCulling: boolean;
  24526. /**
  24527. * Sets the back-face culling state
  24528. */
  24529. set backFaceCulling(value: boolean);
  24530. /**
  24531. * Gets the back-face culling state
  24532. */
  24533. get backFaceCulling(): boolean;
  24534. /**
  24535. * Stores the value for side orientation
  24536. */
  24537. sideOrientation: number;
  24538. /**
  24539. * Callback triggered when the material is compiled
  24540. */
  24541. onCompiled: Nullable<(effect: Effect) => void>;
  24542. /**
  24543. * Callback triggered when an error occurs
  24544. */
  24545. onError: Nullable<(effect: Effect, errors: string) => void>;
  24546. /**
  24547. * Callback triggered to get the render target textures
  24548. */
  24549. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24550. /**
  24551. * Gets a boolean indicating that current material needs to register RTT
  24552. */
  24553. get hasRenderTargetTextures(): boolean;
  24554. /**
  24555. * Specifies if the material should be serialized
  24556. */
  24557. doNotSerialize: boolean;
  24558. /**
  24559. * @hidden
  24560. */
  24561. _storeEffectOnSubMeshes: boolean;
  24562. /**
  24563. * Stores the animations for the material
  24564. */
  24565. animations: Nullable<Array<Animation>>;
  24566. /**
  24567. * An event triggered when the material is disposed
  24568. */
  24569. onDisposeObservable: Observable<Material>;
  24570. /**
  24571. * An observer which watches for dispose events
  24572. */
  24573. private _onDisposeObserver;
  24574. private _onUnBindObservable;
  24575. /**
  24576. * Called during a dispose event
  24577. */
  24578. set onDispose(callback: () => void);
  24579. private _onBindObservable;
  24580. /**
  24581. * An event triggered when the material is bound
  24582. */
  24583. get onBindObservable(): Observable<AbstractMesh>;
  24584. /**
  24585. * An observer which watches for bind events
  24586. */
  24587. private _onBindObserver;
  24588. /**
  24589. * Called during a bind event
  24590. */
  24591. set onBind(callback: (Mesh: AbstractMesh) => void);
  24592. /**
  24593. * An event triggered when the material is unbound
  24594. */
  24595. get onUnBindObservable(): Observable<Material>;
  24596. protected _onEffectCreatedObservable: Nullable<Observable<{
  24597. effect: Effect;
  24598. subMesh: Nullable<SubMesh>;
  24599. }>>;
  24600. /**
  24601. * An event triggered when the effect is (re)created
  24602. */
  24603. get onEffectCreatedObservable(): Observable<{
  24604. effect: Effect;
  24605. subMesh: Nullable<SubMesh>;
  24606. }>;
  24607. /**
  24608. * Stores the value of the alpha mode
  24609. */
  24610. private _alphaMode;
  24611. /**
  24612. * Sets the value of the alpha mode.
  24613. *
  24614. * | Value | Type | Description |
  24615. * | --- | --- | --- |
  24616. * | 0 | ALPHA_DISABLE | |
  24617. * | 1 | ALPHA_ADD | |
  24618. * | 2 | ALPHA_COMBINE | |
  24619. * | 3 | ALPHA_SUBTRACT | |
  24620. * | 4 | ALPHA_MULTIPLY | |
  24621. * | 5 | ALPHA_MAXIMIZED | |
  24622. * | 6 | ALPHA_ONEONE | |
  24623. * | 7 | ALPHA_PREMULTIPLIED | |
  24624. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24625. * | 9 | ALPHA_INTERPOLATE | |
  24626. * | 10 | ALPHA_SCREENMODE | |
  24627. *
  24628. */
  24629. set alphaMode(value: number);
  24630. /**
  24631. * Gets the value of the alpha mode
  24632. */
  24633. get alphaMode(): number;
  24634. /**
  24635. * Stores the state of the need depth pre-pass value
  24636. */
  24637. private _needDepthPrePass;
  24638. /**
  24639. * Sets the need depth pre-pass value
  24640. */
  24641. set needDepthPrePass(value: boolean);
  24642. /**
  24643. * Gets the depth pre-pass value
  24644. */
  24645. get needDepthPrePass(): boolean;
  24646. /**
  24647. * Specifies if depth writing should be disabled
  24648. */
  24649. disableDepthWrite: boolean;
  24650. /**
  24651. * Specifies if color writing should be disabled
  24652. */
  24653. disableColorWrite: boolean;
  24654. /**
  24655. * Specifies if depth writing should be forced
  24656. */
  24657. forceDepthWrite: boolean;
  24658. /**
  24659. * Specifies the depth function that should be used. 0 means the default engine function
  24660. */
  24661. depthFunction: number;
  24662. /**
  24663. * Specifies if there should be a separate pass for culling
  24664. */
  24665. separateCullingPass: boolean;
  24666. /**
  24667. * Stores the state specifing if fog should be enabled
  24668. */
  24669. private _fogEnabled;
  24670. /**
  24671. * Sets the state for enabling fog
  24672. */
  24673. set fogEnabled(value: boolean);
  24674. /**
  24675. * Gets the value of the fog enabled state
  24676. */
  24677. get fogEnabled(): boolean;
  24678. /**
  24679. * Stores the size of points
  24680. */
  24681. pointSize: number;
  24682. /**
  24683. * Stores the z offset value
  24684. */
  24685. zOffset: number;
  24686. get wireframe(): boolean;
  24687. /**
  24688. * Sets the state of wireframe mode
  24689. */
  24690. set wireframe(value: boolean);
  24691. /**
  24692. * Gets the value specifying if point clouds are enabled
  24693. */
  24694. get pointsCloud(): boolean;
  24695. /**
  24696. * Sets the state of point cloud mode
  24697. */
  24698. set pointsCloud(value: boolean);
  24699. /**
  24700. * Gets the material fill mode
  24701. */
  24702. get fillMode(): number;
  24703. /**
  24704. * Sets the material fill mode
  24705. */
  24706. set fillMode(value: number);
  24707. /**
  24708. * @hidden
  24709. * Stores the effects for the material
  24710. */
  24711. _effect: Nullable<Effect>;
  24712. /**
  24713. * Specifies if uniform buffers should be used
  24714. */
  24715. private _useUBO;
  24716. /**
  24717. * Stores a reference to the scene
  24718. */
  24719. private _scene;
  24720. /**
  24721. * Stores the fill mode state
  24722. */
  24723. private _fillMode;
  24724. /**
  24725. * Specifies if the depth write state should be cached
  24726. */
  24727. private _cachedDepthWriteState;
  24728. /**
  24729. * Specifies if the color write state should be cached
  24730. */
  24731. private _cachedColorWriteState;
  24732. /**
  24733. * Specifies if the depth function state should be cached
  24734. */
  24735. private _cachedDepthFunctionState;
  24736. /**
  24737. * Stores the uniform buffer
  24738. */
  24739. protected _uniformBuffer: UniformBuffer;
  24740. /** @hidden */
  24741. _indexInSceneMaterialArray: number;
  24742. /** @hidden */
  24743. meshMap: Nullable<{
  24744. [id: string]: AbstractMesh | undefined;
  24745. }>;
  24746. /**
  24747. * Creates a material instance
  24748. * @param name defines the name of the material
  24749. * @param scene defines the scene to reference
  24750. * @param doNotAdd specifies if the material should be added to the scene
  24751. */
  24752. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24753. /**
  24754. * Returns a string representation of the current material
  24755. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24756. * @returns a string with material information
  24757. */
  24758. toString(fullDetails?: boolean): string;
  24759. /**
  24760. * Gets the class name of the material
  24761. * @returns a string with the class name of the material
  24762. */
  24763. getClassName(): string;
  24764. /**
  24765. * Specifies if updates for the material been locked
  24766. */
  24767. get isFrozen(): boolean;
  24768. /**
  24769. * Locks updates for the material
  24770. */
  24771. freeze(): void;
  24772. /**
  24773. * Unlocks updates for the material
  24774. */
  24775. unfreeze(): void;
  24776. /**
  24777. * Specifies if the material is ready to be used
  24778. * @param mesh defines the mesh to check
  24779. * @param useInstances specifies if instances should be used
  24780. * @returns a boolean indicating if the material is ready to be used
  24781. */
  24782. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24783. /**
  24784. * Specifies that the submesh is ready to be used
  24785. * @param mesh defines the mesh to check
  24786. * @param subMesh defines which submesh to check
  24787. * @param useInstances specifies that instances should be used
  24788. * @returns a boolean indicating that the submesh is ready or not
  24789. */
  24790. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24791. /**
  24792. * Returns the material effect
  24793. * @returns the effect associated with the material
  24794. */
  24795. getEffect(): Nullable<Effect>;
  24796. /**
  24797. * Returns the current scene
  24798. * @returns a Scene
  24799. */
  24800. getScene(): Scene;
  24801. /**
  24802. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24803. */
  24804. protected _forceAlphaTest: boolean;
  24805. /**
  24806. * The transparency mode of the material.
  24807. */
  24808. protected _transparencyMode: Nullable<number>;
  24809. /**
  24810. * Gets the current transparency mode.
  24811. */
  24812. get transparencyMode(): Nullable<number>;
  24813. /**
  24814. * Sets the transparency mode of the material.
  24815. *
  24816. * | Value | Type | Description |
  24817. * | ----- | ----------------------------------- | ----------- |
  24818. * | 0 | OPAQUE | |
  24819. * | 1 | ALPHATEST | |
  24820. * | 2 | ALPHABLEND | |
  24821. * | 3 | ALPHATESTANDBLEND | |
  24822. *
  24823. */
  24824. set transparencyMode(value: Nullable<number>);
  24825. /**
  24826. * Returns true if alpha blending should be disabled.
  24827. */
  24828. protected get _disableAlphaBlending(): boolean;
  24829. /**
  24830. * Specifies whether or not this material should be rendered in alpha blend mode.
  24831. * @returns a boolean specifying if alpha blending is needed
  24832. */
  24833. needAlphaBlending(): boolean;
  24834. /**
  24835. * Specifies if the mesh will require alpha blending
  24836. * @param mesh defines the mesh to check
  24837. * @returns a boolean specifying if alpha blending is needed for the mesh
  24838. */
  24839. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24840. /**
  24841. * Specifies whether or not this material should be rendered in alpha test mode.
  24842. * @returns a boolean specifying if an alpha test is needed.
  24843. */
  24844. needAlphaTesting(): boolean;
  24845. /**
  24846. * Specifies if material alpha testing should be turned on for the mesh
  24847. * @param mesh defines the mesh to check
  24848. */
  24849. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24850. /**
  24851. * Gets the texture used for the alpha test
  24852. * @returns the texture to use for alpha testing
  24853. */
  24854. getAlphaTestTexture(): Nullable<BaseTexture>;
  24855. /**
  24856. * Marks the material to indicate that it needs to be re-calculated
  24857. */
  24858. markDirty(): void;
  24859. /** @hidden */
  24860. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24861. /**
  24862. * Binds the material to the mesh
  24863. * @param world defines the world transformation matrix
  24864. * @param mesh defines the mesh to bind the material to
  24865. */
  24866. bind(world: Matrix, mesh?: Mesh): void;
  24867. /**
  24868. * Binds the submesh to the material
  24869. * @param world defines the world transformation matrix
  24870. * @param mesh defines the mesh containing the submesh
  24871. * @param subMesh defines the submesh to bind the material to
  24872. */
  24873. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24874. /**
  24875. * Binds the world matrix to the material
  24876. * @param world defines the world transformation matrix
  24877. */
  24878. bindOnlyWorldMatrix(world: Matrix): void;
  24879. /**
  24880. * Binds the scene's uniform buffer to the effect.
  24881. * @param effect defines the effect to bind to the scene uniform buffer
  24882. * @param sceneUbo defines the uniform buffer storing scene data
  24883. */
  24884. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24885. /**
  24886. * Binds the view matrix to the effect
  24887. * @param effect defines the effect to bind the view matrix to
  24888. */
  24889. bindView(effect: Effect): void;
  24890. /**
  24891. * Binds the view projection matrix to the effect
  24892. * @param effect defines the effect to bind the view projection matrix to
  24893. */
  24894. bindViewProjection(effect: Effect): void;
  24895. /**
  24896. * Processes to execute after binding the material to a mesh
  24897. * @param mesh defines the rendered mesh
  24898. */
  24899. protected _afterBind(mesh?: Mesh): void;
  24900. /**
  24901. * Unbinds the material from the mesh
  24902. */
  24903. unbind(): void;
  24904. /**
  24905. * Gets the active textures from the material
  24906. * @returns an array of textures
  24907. */
  24908. getActiveTextures(): BaseTexture[];
  24909. /**
  24910. * Specifies if the material uses a texture
  24911. * @param texture defines the texture to check against the material
  24912. * @returns a boolean specifying if the material uses the texture
  24913. */
  24914. hasTexture(texture: BaseTexture): boolean;
  24915. /**
  24916. * Makes a duplicate of the material, and gives it a new name
  24917. * @param name defines the new name for the duplicated material
  24918. * @returns the cloned material
  24919. */
  24920. clone(name: string): Nullable<Material>;
  24921. /**
  24922. * Gets the meshes bound to the material
  24923. * @returns an array of meshes bound to the material
  24924. */
  24925. getBindedMeshes(): AbstractMesh[];
  24926. /**
  24927. * Force shader compilation
  24928. * @param mesh defines the mesh associated with this material
  24929. * @param onCompiled defines a function to execute once the material is compiled
  24930. * @param options defines the options to configure the compilation
  24931. * @param onError defines a function to execute if the material fails compiling
  24932. */
  24933. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24934. /**
  24935. * Force shader compilation
  24936. * @param mesh defines the mesh that will use this material
  24937. * @param options defines additional options for compiling the shaders
  24938. * @returns a promise that resolves when the compilation completes
  24939. */
  24940. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24941. private static readonly _AllDirtyCallBack;
  24942. private static readonly _ImageProcessingDirtyCallBack;
  24943. private static readonly _TextureDirtyCallBack;
  24944. private static readonly _FresnelDirtyCallBack;
  24945. private static readonly _MiscDirtyCallBack;
  24946. private static readonly _LightsDirtyCallBack;
  24947. private static readonly _AttributeDirtyCallBack;
  24948. private static _FresnelAndMiscDirtyCallBack;
  24949. private static _TextureAndMiscDirtyCallBack;
  24950. private static readonly _DirtyCallbackArray;
  24951. private static readonly _RunDirtyCallBacks;
  24952. /**
  24953. * Marks a define in the material to indicate that it needs to be re-computed
  24954. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24955. */
  24956. markAsDirty(flag: number): void;
  24957. /**
  24958. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24959. * @param func defines a function which checks material defines against the submeshes
  24960. */
  24961. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24962. /**
  24963. * Indicates that the scene should check if the rendering now needs a prepass
  24964. */
  24965. protected _markScenePrePassDirty(): void;
  24966. /**
  24967. * Indicates that we need to re-calculated for all submeshes
  24968. */
  24969. protected _markAllSubMeshesAsAllDirty(): void;
  24970. /**
  24971. * Indicates that image processing needs to be re-calculated for all submeshes
  24972. */
  24973. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24974. /**
  24975. * Indicates that textures need to be re-calculated for all submeshes
  24976. */
  24977. protected _markAllSubMeshesAsTexturesDirty(): void;
  24978. /**
  24979. * Indicates that fresnel needs to be re-calculated for all submeshes
  24980. */
  24981. protected _markAllSubMeshesAsFresnelDirty(): void;
  24982. /**
  24983. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24984. */
  24985. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24986. /**
  24987. * Indicates that lights need to be re-calculated for all submeshes
  24988. */
  24989. protected _markAllSubMeshesAsLightsDirty(): void;
  24990. /**
  24991. * Indicates that attributes need to be re-calculated for all submeshes
  24992. */
  24993. protected _markAllSubMeshesAsAttributesDirty(): void;
  24994. /**
  24995. * Indicates that misc needs to be re-calculated for all submeshes
  24996. */
  24997. protected _markAllSubMeshesAsMiscDirty(): void;
  24998. /**
  24999. * Indicates that textures and misc need to be re-calculated for all submeshes
  25000. */
  25001. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25002. /**
  25003. * Sets the required values to the prepass renderer.
  25004. * @param prePassRenderer defines the prepass renderer to setup.
  25005. * @returns true if the pre pass is needed.
  25006. */
  25007. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25008. /**
  25009. * Disposes the material
  25010. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25011. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25012. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25013. */
  25014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25015. /** @hidden */
  25016. private releaseVertexArrayObject;
  25017. /**
  25018. * Serializes this material
  25019. * @returns the serialized material object
  25020. */
  25021. serialize(): any;
  25022. /**
  25023. * Creates a material from parsed material data
  25024. * @param parsedMaterial defines parsed material data
  25025. * @param scene defines the hosting scene
  25026. * @param rootUrl defines the root URL to use to load textures
  25027. * @returns a new material
  25028. */
  25029. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25030. }
  25031. }
  25032. declare module BABYLON {
  25033. /**
  25034. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25035. * separate meshes. This can be use to improve performances.
  25036. * @see https://doc.babylonjs.com/how_to/multi_materials
  25037. */
  25038. export class MultiMaterial extends Material {
  25039. private _subMaterials;
  25040. /**
  25041. * Gets or Sets the list of Materials used within the multi material.
  25042. * They need to be ordered according to the submeshes order in the associated mesh
  25043. */
  25044. get subMaterials(): Nullable<Material>[];
  25045. set subMaterials(value: Nullable<Material>[]);
  25046. /**
  25047. * Function used to align with Node.getChildren()
  25048. * @returns the list of Materials used within the multi material
  25049. */
  25050. getChildren(): Nullable<Material>[];
  25051. /**
  25052. * Instantiates a new Multi Material
  25053. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25054. * separate meshes. This can be use to improve performances.
  25055. * @see https://doc.babylonjs.com/how_to/multi_materials
  25056. * @param name Define the name in the scene
  25057. * @param scene Define the scene the material belongs to
  25058. */
  25059. constructor(name: string, scene: Scene);
  25060. private _hookArray;
  25061. /**
  25062. * Get one of the submaterial by its index in the submaterials array
  25063. * @param index The index to look the sub material at
  25064. * @returns The Material if the index has been defined
  25065. */
  25066. getSubMaterial(index: number): Nullable<Material>;
  25067. /**
  25068. * Get the list of active textures for the whole sub materials list.
  25069. * @returns All the textures that will be used during the rendering
  25070. */
  25071. getActiveTextures(): BaseTexture[];
  25072. /**
  25073. * Gets the current class name of the material e.g. "MultiMaterial"
  25074. * Mainly use in serialization.
  25075. * @returns the class name
  25076. */
  25077. getClassName(): string;
  25078. /**
  25079. * Checks if the material is ready to render the requested sub mesh
  25080. * @param mesh Define the mesh the submesh belongs to
  25081. * @param subMesh Define the sub mesh to look readyness for
  25082. * @param useInstances Define whether or not the material is used with instances
  25083. * @returns true if ready, otherwise false
  25084. */
  25085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25086. /**
  25087. * Clones the current material and its related sub materials
  25088. * @param name Define the name of the newly cloned material
  25089. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25090. * @returns the cloned material
  25091. */
  25092. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25093. /**
  25094. * Serializes the materials into a JSON representation.
  25095. * @returns the JSON representation
  25096. */
  25097. serialize(): any;
  25098. /**
  25099. * Dispose the material and release its associated resources
  25100. * @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)
  25101. * @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)
  25102. * @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)
  25103. */
  25104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25105. /**
  25106. * Creates a MultiMaterial from parsed MultiMaterial data.
  25107. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25108. * @param scene defines the hosting scene
  25109. * @returns a new MultiMaterial
  25110. */
  25111. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25112. }
  25113. }
  25114. declare module BABYLON {
  25115. /**
  25116. * Defines a subdivision inside a mesh
  25117. */
  25118. export class SubMesh implements ICullable {
  25119. /** the material index to use */
  25120. materialIndex: number;
  25121. /** vertex index start */
  25122. verticesStart: number;
  25123. /** vertices count */
  25124. verticesCount: number;
  25125. /** index start */
  25126. indexStart: number;
  25127. /** indices count */
  25128. indexCount: number;
  25129. /** @hidden */
  25130. _materialDefines: Nullable<MaterialDefines>;
  25131. /** @hidden */
  25132. _materialEffect: Nullable<Effect>;
  25133. /** @hidden */
  25134. _effectOverride: Nullable<Effect>;
  25135. /**
  25136. * Gets material defines used by the effect associated to the sub mesh
  25137. */
  25138. get materialDefines(): Nullable<MaterialDefines>;
  25139. /**
  25140. * Sets material defines used by the effect associated to the sub mesh
  25141. */
  25142. set materialDefines(defines: Nullable<MaterialDefines>);
  25143. /**
  25144. * Gets associated effect
  25145. */
  25146. get effect(): Nullable<Effect>;
  25147. /**
  25148. * Sets associated effect (effect used to render this submesh)
  25149. * @param effect defines the effect to associate with
  25150. * @param defines defines the set of defines used to compile this effect
  25151. */
  25152. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25153. /** @hidden */
  25154. _linesIndexCount: number;
  25155. private _mesh;
  25156. private _renderingMesh;
  25157. private _boundingInfo;
  25158. private _linesIndexBuffer;
  25159. /** @hidden */
  25160. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25161. /** @hidden */
  25162. _trianglePlanes: Plane[];
  25163. /** @hidden */
  25164. _lastColliderTransformMatrix: Nullable<Matrix>;
  25165. /** @hidden */
  25166. _renderId: number;
  25167. /** @hidden */
  25168. _alphaIndex: number;
  25169. /** @hidden */
  25170. _distanceToCamera: number;
  25171. /** @hidden */
  25172. _id: number;
  25173. private _currentMaterial;
  25174. /**
  25175. * Add a new submesh to a mesh
  25176. * @param materialIndex defines the material index to use
  25177. * @param verticesStart defines vertex index start
  25178. * @param verticesCount defines vertices count
  25179. * @param indexStart defines index start
  25180. * @param indexCount defines indices count
  25181. * @param mesh defines the parent mesh
  25182. * @param renderingMesh defines an optional rendering mesh
  25183. * @param createBoundingBox defines if bounding box should be created for this submesh
  25184. * @returns the new submesh
  25185. */
  25186. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25187. /**
  25188. * Creates a new submesh
  25189. * @param materialIndex defines the material index to use
  25190. * @param verticesStart defines vertex index start
  25191. * @param verticesCount defines vertices count
  25192. * @param indexStart defines index start
  25193. * @param indexCount defines indices count
  25194. * @param mesh defines the parent mesh
  25195. * @param renderingMesh defines an optional rendering mesh
  25196. * @param createBoundingBox defines if bounding box should be created for this submesh
  25197. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25198. */
  25199. constructor(
  25200. /** the material index to use */
  25201. materialIndex: number,
  25202. /** vertex index start */
  25203. verticesStart: number,
  25204. /** vertices count */
  25205. verticesCount: number,
  25206. /** index start */
  25207. indexStart: number,
  25208. /** indices count */
  25209. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25210. /**
  25211. * Returns true if this submesh covers the entire parent mesh
  25212. * @ignorenaming
  25213. */
  25214. get IsGlobal(): boolean;
  25215. /**
  25216. * Returns the submesh BoudingInfo object
  25217. * @returns current bounding info (or mesh's one if the submesh is global)
  25218. */
  25219. getBoundingInfo(): BoundingInfo;
  25220. /**
  25221. * Sets the submesh BoundingInfo
  25222. * @param boundingInfo defines the new bounding info to use
  25223. * @returns the SubMesh
  25224. */
  25225. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25226. /**
  25227. * Returns the mesh of the current submesh
  25228. * @return the parent mesh
  25229. */
  25230. getMesh(): AbstractMesh;
  25231. /**
  25232. * Returns the rendering mesh of the submesh
  25233. * @returns the rendering mesh (could be different from parent mesh)
  25234. */
  25235. getRenderingMesh(): Mesh;
  25236. /**
  25237. * Returns the replacement mesh of the submesh
  25238. * @returns the replacement mesh (could be different from parent mesh)
  25239. */
  25240. getReplacementMesh(): Nullable<AbstractMesh>;
  25241. /**
  25242. * Returns the effective mesh of the submesh
  25243. * @returns the effective mesh (could be different from parent mesh)
  25244. */
  25245. getEffectiveMesh(): AbstractMesh;
  25246. /**
  25247. * Returns the submesh material
  25248. * @returns null or the current material
  25249. */
  25250. getMaterial(): Nullable<Material>;
  25251. private _IsMultiMaterial;
  25252. /**
  25253. * Sets a new updated BoundingInfo object to the submesh
  25254. * @param data defines an optional position array to use to determine the bounding info
  25255. * @returns the SubMesh
  25256. */
  25257. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25258. /** @hidden */
  25259. _checkCollision(collider: Collider): boolean;
  25260. /**
  25261. * Updates the submesh BoundingInfo
  25262. * @param world defines the world matrix to use to update the bounding info
  25263. * @returns the submesh
  25264. */
  25265. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25266. /**
  25267. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25268. * @param frustumPlanes defines the frustum planes
  25269. * @returns true if the submesh is intersecting with the frustum
  25270. */
  25271. isInFrustum(frustumPlanes: Plane[]): boolean;
  25272. /**
  25273. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25274. * @param frustumPlanes defines the frustum planes
  25275. * @returns true if the submesh is inside the frustum
  25276. */
  25277. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25278. /**
  25279. * Renders the submesh
  25280. * @param enableAlphaMode defines if alpha needs to be used
  25281. * @returns the submesh
  25282. */
  25283. render(enableAlphaMode: boolean): SubMesh;
  25284. /**
  25285. * @hidden
  25286. */
  25287. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25288. /**
  25289. * Checks if the submesh intersects with a ray
  25290. * @param ray defines the ray to test
  25291. * @returns true is the passed ray intersects the submesh bounding box
  25292. */
  25293. canIntersects(ray: Ray): boolean;
  25294. /**
  25295. * Intersects current submesh with a ray
  25296. * @param ray defines the ray to test
  25297. * @param positions defines mesh's positions array
  25298. * @param indices defines mesh's indices array
  25299. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25300. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25301. * @returns intersection info or null if no intersection
  25302. */
  25303. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25304. /** @hidden */
  25305. private _intersectLines;
  25306. /** @hidden */
  25307. private _intersectUnIndexedLines;
  25308. /** @hidden */
  25309. private _intersectTriangles;
  25310. /** @hidden */
  25311. private _intersectUnIndexedTriangles;
  25312. /** @hidden */
  25313. _rebuild(): void;
  25314. /**
  25315. * Creates a new submesh from the passed mesh
  25316. * @param newMesh defines the new hosting mesh
  25317. * @param newRenderingMesh defines an optional rendering mesh
  25318. * @returns the new submesh
  25319. */
  25320. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25321. /**
  25322. * Release associated resources
  25323. */
  25324. dispose(): void;
  25325. /**
  25326. * Gets the class name
  25327. * @returns the string "SubMesh".
  25328. */
  25329. getClassName(): string;
  25330. /**
  25331. * Creates a new submesh from indices data
  25332. * @param materialIndex the index of the main mesh material
  25333. * @param startIndex the index where to start the copy in the mesh indices array
  25334. * @param indexCount the number of indices to copy then from the startIndex
  25335. * @param mesh the main mesh to create the submesh from
  25336. * @param renderingMesh the optional rendering mesh
  25337. * @returns a new submesh
  25338. */
  25339. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25340. }
  25341. }
  25342. declare module BABYLON {
  25343. /**
  25344. * Class used to represent data loading progression
  25345. */
  25346. export class SceneLoaderFlags {
  25347. private static _ForceFullSceneLoadingForIncremental;
  25348. private static _ShowLoadingScreen;
  25349. private static _CleanBoneMatrixWeights;
  25350. private static _loggingLevel;
  25351. /**
  25352. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25353. */
  25354. static get ForceFullSceneLoadingForIncremental(): boolean;
  25355. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25356. /**
  25357. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25358. */
  25359. static get ShowLoadingScreen(): boolean;
  25360. static set ShowLoadingScreen(value: boolean);
  25361. /**
  25362. * Defines the current logging level (while loading the scene)
  25363. * @ignorenaming
  25364. */
  25365. static get loggingLevel(): number;
  25366. static set loggingLevel(value: number);
  25367. /**
  25368. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25369. */
  25370. static get CleanBoneMatrixWeights(): boolean;
  25371. static set CleanBoneMatrixWeights(value: boolean);
  25372. }
  25373. }
  25374. declare module BABYLON {
  25375. /**
  25376. * Class used to store geometry data (vertex buffers + index buffer)
  25377. */
  25378. export class Geometry implements IGetSetVerticesData {
  25379. /**
  25380. * Gets or sets the ID of the geometry
  25381. */
  25382. id: string;
  25383. /**
  25384. * Gets or sets the unique ID of the geometry
  25385. */
  25386. uniqueId: number;
  25387. /**
  25388. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25389. */
  25390. delayLoadState: number;
  25391. /**
  25392. * Gets the file containing the data to load when running in delay load state
  25393. */
  25394. delayLoadingFile: Nullable<string>;
  25395. /**
  25396. * Callback called when the geometry is updated
  25397. */
  25398. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25399. private _scene;
  25400. private _engine;
  25401. private _meshes;
  25402. private _totalVertices;
  25403. /** @hidden */
  25404. _indices: IndicesArray;
  25405. /** @hidden */
  25406. _vertexBuffers: {
  25407. [key: string]: VertexBuffer;
  25408. };
  25409. private _isDisposed;
  25410. private _extend;
  25411. private _boundingBias;
  25412. /** @hidden */
  25413. _delayInfo: Array<string>;
  25414. private _indexBuffer;
  25415. private _indexBufferIsUpdatable;
  25416. /** @hidden */
  25417. _boundingInfo: Nullable<BoundingInfo>;
  25418. /** @hidden */
  25419. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25420. /** @hidden */
  25421. _softwareSkinningFrameId: number;
  25422. private _vertexArrayObjects;
  25423. private _updatable;
  25424. /** @hidden */
  25425. _positions: Nullable<Vector3[]>;
  25426. /**
  25427. * 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
  25428. */
  25429. get boundingBias(): Vector2;
  25430. /**
  25431. * 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
  25432. */
  25433. set boundingBias(value: Vector2);
  25434. /**
  25435. * Static function used to attach a new empty geometry to a mesh
  25436. * @param mesh defines the mesh to attach the geometry to
  25437. * @returns the new Geometry
  25438. */
  25439. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25440. /** Get the list of meshes using this geometry */
  25441. get meshes(): Mesh[];
  25442. /**
  25443. * 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
  25444. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25445. */
  25446. useBoundingInfoFromGeometry: boolean;
  25447. /**
  25448. * Creates a new geometry
  25449. * @param id defines the unique ID
  25450. * @param scene defines the hosting scene
  25451. * @param vertexData defines the VertexData used to get geometry data
  25452. * @param updatable defines if geometry must be updatable (false by default)
  25453. * @param mesh defines the mesh that will be associated with the geometry
  25454. */
  25455. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25456. /**
  25457. * Gets the current extend of the geometry
  25458. */
  25459. get extend(): {
  25460. minimum: Vector3;
  25461. maximum: Vector3;
  25462. };
  25463. /**
  25464. * Gets the hosting scene
  25465. * @returns the hosting Scene
  25466. */
  25467. getScene(): Scene;
  25468. /**
  25469. * Gets the hosting engine
  25470. * @returns the hosting Engine
  25471. */
  25472. getEngine(): Engine;
  25473. /**
  25474. * Defines if the geometry is ready to use
  25475. * @returns true if the geometry is ready to be used
  25476. */
  25477. isReady(): boolean;
  25478. /**
  25479. * Gets a value indicating that the geometry should not be serialized
  25480. */
  25481. get doNotSerialize(): boolean;
  25482. /** @hidden */
  25483. _rebuild(): void;
  25484. /**
  25485. * Affects all geometry data in one call
  25486. * @param vertexData defines the geometry data
  25487. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25488. */
  25489. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25490. /**
  25491. * Set specific vertex data
  25492. * @param kind defines the data kind (Position, normal, etc...)
  25493. * @param data defines the vertex data to use
  25494. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25495. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25496. */
  25497. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25498. /**
  25499. * Removes a specific vertex data
  25500. * @param kind defines the data kind (Position, normal, etc...)
  25501. */
  25502. removeVerticesData(kind: string): void;
  25503. /**
  25504. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25505. * @param buffer defines the vertex buffer to use
  25506. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25507. */
  25508. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25509. /**
  25510. * Update a specific vertex buffer
  25511. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25512. * It will do nothing if the buffer is not updatable
  25513. * @param kind defines the data kind (Position, normal, etc...)
  25514. * @param data defines the data to use
  25515. * @param offset defines the offset in the target buffer where to store the data
  25516. * @param useBytes set to true if the offset is in bytes
  25517. */
  25518. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25519. /**
  25520. * Update a specific vertex buffer
  25521. * This function will create a new buffer if the current one is not updatable
  25522. * @param kind defines the data kind (Position, normal, etc...)
  25523. * @param data defines the data to use
  25524. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25525. */
  25526. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25527. private _updateBoundingInfo;
  25528. /** @hidden */
  25529. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25530. /**
  25531. * Gets total number of vertices
  25532. * @returns the total number of vertices
  25533. */
  25534. getTotalVertices(): number;
  25535. /**
  25536. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25537. * @param kind defines the data kind (Position, normal, etc...)
  25538. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25540. * @returns a float array containing vertex data
  25541. */
  25542. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25543. /**
  25544. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25545. * @param kind defines the data kind (Position, normal, etc...)
  25546. * @returns true if the vertex buffer with the specified kind is updatable
  25547. */
  25548. isVertexBufferUpdatable(kind: string): boolean;
  25549. /**
  25550. * Gets a specific vertex buffer
  25551. * @param kind defines the data kind (Position, normal, etc...)
  25552. * @returns a VertexBuffer
  25553. */
  25554. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25555. /**
  25556. * Returns all vertex buffers
  25557. * @return an object holding all vertex buffers indexed by kind
  25558. */
  25559. getVertexBuffers(): Nullable<{
  25560. [key: string]: VertexBuffer;
  25561. }>;
  25562. /**
  25563. * Gets a boolean indicating if specific vertex buffer is present
  25564. * @param kind defines the data kind (Position, normal, etc...)
  25565. * @returns true if data is present
  25566. */
  25567. isVerticesDataPresent(kind: string): boolean;
  25568. /**
  25569. * Gets a list of all attached data kinds (Position, normal, etc...)
  25570. * @returns a list of string containing all kinds
  25571. */
  25572. getVerticesDataKinds(): string[];
  25573. /**
  25574. * Update index buffer
  25575. * @param indices defines the indices to store in the index buffer
  25576. * @param offset defines the offset in the target buffer where to store the data
  25577. * @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)
  25578. */
  25579. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25580. /**
  25581. * Creates a new index buffer
  25582. * @param indices defines the indices to store in the index buffer
  25583. * @param totalVertices defines the total number of vertices (could be null)
  25584. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25585. */
  25586. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25587. /**
  25588. * Return the total number of indices
  25589. * @returns the total number of indices
  25590. */
  25591. getTotalIndices(): number;
  25592. /**
  25593. * Gets the index buffer array
  25594. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25595. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25596. * @returns the index buffer array
  25597. */
  25598. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25599. /**
  25600. * Gets the index buffer
  25601. * @return the index buffer
  25602. */
  25603. getIndexBuffer(): Nullable<DataBuffer>;
  25604. /** @hidden */
  25605. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25606. /**
  25607. * Release the associated resources for a specific mesh
  25608. * @param mesh defines the source mesh
  25609. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25610. */
  25611. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25612. /**
  25613. * Apply current geometry to a given mesh
  25614. * @param mesh defines the mesh to apply geometry to
  25615. */
  25616. applyToMesh(mesh: Mesh): void;
  25617. private _updateExtend;
  25618. private _applyToMesh;
  25619. private notifyUpdate;
  25620. /**
  25621. * Load the geometry if it was flagged as delay loaded
  25622. * @param scene defines the hosting scene
  25623. * @param onLoaded defines a callback called when the geometry is loaded
  25624. */
  25625. load(scene: Scene, onLoaded?: () => void): void;
  25626. private _queueLoad;
  25627. /**
  25628. * Invert the geometry to move from a right handed system to a left handed one.
  25629. */
  25630. toLeftHanded(): void;
  25631. /** @hidden */
  25632. _resetPointsArrayCache(): void;
  25633. /** @hidden */
  25634. _generatePointsArray(): boolean;
  25635. /**
  25636. * Gets a value indicating if the geometry is disposed
  25637. * @returns true if the geometry was disposed
  25638. */
  25639. isDisposed(): boolean;
  25640. private _disposeVertexArrayObjects;
  25641. /**
  25642. * Free all associated resources
  25643. */
  25644. dispose(): void;
  25645. /**
  25646. * Clone the current geometry into a new geometry
  25647. * @param id defines the unique ID of the new geometry
  25648. * @returns a new geometry object
  25649. */
  25650. copy(id: string): Geometry;
  25651. /**
  25652. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25653. * @return a JSON representation of the current geometry data (without the vertices data)
  25654. */
  25655. serialize(): any;
  25656. private toNumberArray;
  25657. /**
  25658. * Serialize all vertices data into a JSON oject
  25659. * @returns a JSON representation of the current geometry data
  25660. */
  25661. serializeVerticeData(): any;
  25662. /**
  25663. * Extracts a clone of a mesh geometry
  25664. * @param mesh defines the source mesh
  25665. * @param id defines the unique ID of the new geometry object
  25666. * @returns the new geometry object
  25667. */
  25668. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25669. /**
  25670. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25671. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25672. * Be aware Math.random() could cause collisions, but:
  25673. * "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"
  25674. * @returns a string containing a new GUID
  25675. */
  25676. static RandomId(): string;
  25677. /** @hidden */
  25678. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25679. private static _CleanMatricesWeights;
  25680. /**
  25681. * Create a new geometry from persisted data (Using .babylon file format)
  25682. * @param parsedVertexData defines the persisted data
  25683. * @param scene defines the hosting scene
  25684. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25685. * @returns the new geometry object
  25686. */
  25687. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25688. }
  25689. }
  25690. declare module BABYLON {
  25691. /**
  25692. * Define an interface for all classes that will get and set the data on vertices
  25693. */
  25694. export interface IGetSetVerticesData {
  25695. /**
  25696. * Gets a boolean indicating if specific vertex data is present
  25697. * @param kind defines the vertex data kind to use
  25698. * @returns true is data kind is present
  25699. */
  25700. isVerticesDataPresent(kind: string): boolean;
  25701. /**
  25702. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25703. * @param kind defines the data kind (Position, normal, etc...)
  25704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25706. * @returns a float array containing vertex data
  25707. */
  25708. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25709. /**
  25710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25711. * @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.
  25712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25713. * @returns the indices array or an empty array if the mesh has no geometry
  25714. */
  25715. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25716. /**
  25717. * Set specific vertex data
  25718. * @param kind defines the data kind (Position, normal, etc...)
  25719. * @param data defines the vertex data to use
  25720. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25721. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25722. */
  25723. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25724. /**
  25725. * Update a specific associated vertex buffer
  25726. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25727. * - VertexBuffer.PositionKind
  25728. * - VertexBuffer.UVKind
  25729. * - VertexBuffer.UV2Kind
  25730. * - VertexBuffer.UV3Kind
  25731. * - VertexBuffer.UV4Kind
  25732. * - VertexBuffer.UV5Kind
  25733. * - VertexBuffer.UV6Kind
  25734. * - VertexBuffer.ColorKind
  25735. * - VertexBuffer.MatricesIndicesKind
  25736. * - VertexBuffer.MatricesIndicesExtraKind
  25737. * - VertexBuffer.MatricesWeightsKind
  25738. * - VertexBuffer.MatricesWeightsExtraKind
  25739. * @param data defines the data source
  25740. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25741. * @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)
  25742. */
  25743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25744. /**
  25745. * Creates a new index buffer
  25746. * @param indices defines the indices to store in the index buffer
  25747. * @param totalVertices defines the total number of vertices (could be null)
  25748. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25749. */
  25750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25751. }
  25752. /**
  25753. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25754. */
  25755. export class VertexData {
  25756. /**
  25757. * Mesh side orientation : usually the external or front surface
  25758. */
  25759. static readonly FRONTSIDE: number;
  25760. /**
  25761. * Mesh side orientation : usually the internal or back surface
  25762. */
  25763. static readonly BACKSIDE: number;
  25764. /**
  25765. * Mesh side orientation : both internal and external or front and back surfaces
  25766. */
  25767. static readonly DOUBLESIDE: number;
  25768. /**
  25769. * Mesh side orientation : by default, `FRONTSIDE`
  25770. */
  25771. static readonly DEFAULTSIDE: number;
  25772. /**
  25773. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25774. */
  25775. positions: Nullable<FloatArray>;
  25776. /**
  25777. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25778. */
  25779. normals: Nullable<FloatArray>;
  25780. /**
  25781. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25782. */
  25783. tangents: Nullable<FloatArray>;
  25784. /**
  25785. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25786. */
  25787. uvs: Nullable<FloatArray>;
  25788. /**
  25789. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25790. */
  25791. uvs2: Nullable<FloatArray>;
  25792. /**
  25793. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25794. */
  25795. uvs3: Nullable<FloatArray>;
  25796. /**
  25797. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25798. */
  25799. uvs4: Nullable<FloatArray>;
  25800. /**
  25801. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25802. */
  25803. uvs5: Nullable<FloatArray>;
  25804. /**
  25805. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25806. */
  25807. uvs6: Nullable<FloatArray>;
  25808. /**
  25809. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25810. */
  25811. colors: Nullable<FloatArray>;
  25812. /**
  25813. * 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).
  25814. */
  25815. matricesIndices: Nullable<FloatArray>;
  25816. /**
  25817. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25818. */
  25819. matricesWeights: Nullable<FloatArray>;
  25820. /**
  25821. * An array extending the number of possible indices
  25822. */
  25823. matricesIndicesExtra: Nullable<FloatArray>;
  25824. /**
  25825. * An array extending the number of possible weights when the number of indices is extended
  25826. */
  25827. matricesWeightsExtra: Nullable<FloatArray>;
  25828. /**
  25829. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25830. */
  25831. indices: Nullable<IndicesArray>;
  25832. /**
  25833. * Uses the passed data array to set the set the values for the specified kind of data
  25834. * @param data a linear array of floating numbers
  25835. * @param kind the type of data that is being set, eg positions, colors etc
  25836. */
  25837. set(data: FloatArray, kind: string): void;
  25838. /**
  25839. * Associates the vertexData to the passed Mesh.
  25840. * Sets it as updatable or not (default `false`)
  25841. * @param mesh the mesh the vertexData is applied to
  25842. * @param updatable when used and having the value true allows new data to update the vertexData
  25843. * @returns the VertexData
  25844. */
  25845. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25846. /**
  25847. * Associates the vertexData to the passed Geometry.
  25848. * Sets it as updatable or not (default `false`)
  25849. * @param geometry the geometry the vertexData is applied to
  25850. * @param updatable when used and having the value true allows new data to update the vertexData
  25851. * @returns VertexData
  25852. */
  25853. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25854. /**
  25855. * Updates the associated mesh
  25856. * @param mesh the mesh to be updated
  25857. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25858. * @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
  25859. * @returns VertexData
  25860. */
  25861. updateMesh(mesh: Mesh): VertexData;
  25862. /**
  25863. * Updates the associated geometry
  25864. * @param geometry the geometry to be updated
  25865. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25866. * @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
  25867. * @returns VertexData.
  25868. */
  25869. updateGeometry(geometry: Geometry): VertexData;
  25870. private _applyTo;
  25871. private _update;
  25872. /**
  25873. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25874. * @param matrix the transforming matrix
  25875. * @returns the VertexData
  25876. */
  25877. transform(matrix: Matrix): VertexData;
  25878. /**
  25879. * Merges the passed VertexData into the current one
  25880. * @param other the VertexData to be merged into the current one
  25881. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25882. * @returns the modified VertexData
  25883. */
  25884. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25885. private _mergeElement;
  25886. private _validate;
  25887. /**
  25888. * Serializes the VertexData
  25889. * @returns a serialized object
  25890. */
  25891. serialize(): any;
  25892. /**
  25893. * Extracts the vertexData from a mesh
  25894. * @param mesh the mesh from which to extract the VertexData
  25895. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25897. * @returns the object VertexData associated to the passed mesh
  25898. */
  25899. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25900. /**
  25901. * Extracts the vertexData from the geometry
  25902. * @param geometry the geometry from which to extract the VertexData
  25903. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25905. * @returns the object VertexData associated to the passed mesh
  25906. */
  25907. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25908. private static _ExtractFrom;
  25909. /**
  25910. * Creates the VertexData for a Ribbon
  25911. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25912. * * pathArray array of paths, each of which an array of successive Vector3
  25913. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25914. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25915. * * 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
  25916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25917. * * 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)
  25918. * * 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)
  25919. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25920. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25921. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25922. * @returns the VertexData of the ribbon
  25923. */
  25924. static CreateRibbon(options: {
  25925. pathArray: Vector3[][];
  25926. closeArray?: boolean;
  25927. closePath?: boolean;
  25928. offset?: number;
  25929. sideOrientation?: number;
  25930. frontUVs?: Vector4;
  25931. backUVs?: Vector4;
  25932. invertUV?: boolean;
  25933. uvs?: Vector2[];
  25934. colors?: Color4[];
  25935. }): VertexData;
  25936. /**
  25937. * Creates the VertexData for a box
  25938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25939. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25940. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25941. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25942. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25943. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25944. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25946. * * 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)
  25947. * * 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)
  25948. * @returns the VertexData of the box
  25949. */
  25950. static CreateBox(options: {
  25951. size?: number;
  25952. width?: number;
  25953. height?: number;
  25954. depth?: number;
  25955. faceUV?: Vector4[];
  25956. faceColors?: Color4[];
  25957. sideOrientation?: number;
  25958. frontUVs?: Vector4;
  25959. backUVs?: Vector4;
  25960. }): VertexData;
  25961. /**
  25962. * Creates the VertexData for a tiled box
  25963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25965. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25966. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25968. * @returns the VertexData of the box
  25969. */
  25970. static CreateTiledBox(options: {
  25971. pattern?: number;
  25972. width?: number;
  25973. height?: number;
  25974. depth?: number;
  25975. tileSize?: number;
  25976. tileWidth?: number;
  25977. tileHeight?: number;
  25978. alignHorizontal?: number;
  25979. alignVertical?: number;
  25980. faceUV?: Vector4[];
  25981. faceColors?: Color4[];
  25982. sideOrientation?: number;
  25983. }): VertexData;
  25984. /**
  25985. * Creates the VertexData for a tiled plane
  25986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25987. * * pattern a limited pattern arrangement depending on the number
  25988. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25989. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25990. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25992. * * 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)
  25993. * * 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)
  25994. * @returns the VertexData of the tiled plane
  25995. */
  25996. static CreateTiledPlane(options: {
  25997. pattern?: number;
  25998. tileSize?: number;
  25999. tileWidth?: number;
  26000. tileHeight?: number;
  26001. size?: number;
  26002. width?: number;
  26003. height?: number;
  26004. alignHorizontal?: number;
  26005. alignVertical?: number;
  26006. sideOrientation?: number;
  26007. frontUVs?: Vector4;
  26008. backUVs?: Vector4;
  26009. }): VertexData;
  26010. /**
  26011. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26013. * * segments sets the number of horizontal strips optional, default 32
  26014. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26015. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26016. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26017. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26018. * * 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
  26019. * * 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
  26020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26021. * * 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)
  26022. * * 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)
  26023. * @returns the VertexData of the ellipsoid
  26024. */
  26025. static CreateSphere(options: {
  26026. segments?: number;
  26027. diameter?: number;
  26028. diameterX?: number;
  26029. diameterY?: number;
  26030. diameterZ?: number;
  26031. arc?: number;
  26032. slice?: number;
  26033. sideOrientation?: number;
  26034. frontUVs?: Vector4;
  26035. backUVs?: Vector4;
  26036. }): VertexData;
  26037. /**
  26038. * Creates the VertexData for a cylinder, cone or prism
  26039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26040. * * height sets the height (y direction) of the cylinder, optional, default 2
  26041. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26042. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26043. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26044. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26045. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26046. * * 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
  26047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26049. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26050. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26052. * * 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)
  26053. * * 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)
  26054. * @returns the VertexData of the cylinder, cone or prism
  26055. */
  26056. static CreateCylinder(options: {
  26057. height?: number;
  26058. diameterTop?: number;
  26059. diameterBottom?: number;
  26060. diameter?: number;
  26061. tessellation?: number;
  26062. subdivisions?: number;
  26063. arc?: number;
  26064. faceColors?: Color4[];
  26065. faceUV?: Vector4[];
  26066. hasRings?: boolean;
  26067. enclose?: boolean;
  26068. sideOrientation?: number;
  26069. frontUVs?: Vector4;
  26070. backUVs?: Vector4;
  26071. }): VertexData;
  26072. /**
  26073. * Creates the VertexData for a torus
  26074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26075. * * diameter the diameter of the torus, optional default 1
  26076. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26077. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26079. * * 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)
  26080. * * 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)
  26081. * @returns the VertexData of the torus
  26082. */
  26083. static CreateTorus(options: {
  26084. diameter?: number;
  26085. thickness?: number;
  26086. tessellation?: number;
  26087. sideOrientation?: number;
  26088. frontUVs?: Vector4;
  26089. backUVs?: Vector4;
  26090. }): VertexData;
  26091. /**
  26092. * Creates the VertexData of the LineSystem
  26093. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26094. * - lines an array of lines, each line being an array of successive Vector3
  26095. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26096. * @returns the VertexData of the LineSystem
  26097. */
  26098. static CreateLineSystem(options: {
  26099. lines: Vector3[][];
  26100. colors?: Nullable<Color4[][]>;
  26101. }): VertexData;
  26102. /**
  26103. * Create the VertexData for a DashedLines
  26104. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26105. * - points an array successive Vector3
  26106. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26107. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26108. * - dashNb the intended total number of dashes, optional, default 200
  26109. * @returns the VertexData for the DashedLines
  26110. */
  26111. static CreateDashedLines(options: {
  26112. points: Vector3[];
  26113. dashSize?: number;
  26114. gapSize?: number;
  26115. dashNb?: number;
  26116. }): VertexData;
  26117. /**
  26118. * Creates the VertexData for a Ground
  26119. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26120. * - width the width (x direction) of the ground, optional, default 1
  26121. * - height the height (z direction) of the ground, optional, default 1
  26122. * - subdivisions the number of subdivisions per side, optional, default 1
  26123. * @returns the VertexData of the Ground
  26124. */
  26125. static CreateGround(options: {
  26126. width?: number;
  26127. height?: number;
  26128. subdivisions?: number;
  26129. subdivisionsX?: number;
  26130. subdivisionsY?: number;
  26131. }): VertexData;
  26132. /**
  26133. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26134. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26135. * * xmin the ground minimum X coordinate, optional, default -1
  26136. * * zmin the ground minimum Z coordinate, optional, default -1
  26137. * * xmax the ground maximum X coordinate, optional, default 1
  26138. * * zmax the ground maximum Z coordinate, optional, default 1
  26139. * * 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}
  26140. * * 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}
  26141. * @returns the VertexData of the TiledGround
  26142. */
  26143. static CreateTiledGround(options: {
  26144. xmin: number;
  26145. zmin: number;
  26146. xmax: number;
  26147. zmax: number;
  26148. subdivisions?: {
  26149. w: number;
  26150. h: number;
  26151. };
  26152. precision?: {
  26153. w: number;
  26154. h: number;
  26155. };
  26156. }): VertexData;
  26157. /**
  26158. * Creates the VertexData of the Ground designed from a heightmap
  26159. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26160. * * width the width (x direction) of the ground
  26161. * * height the height (z direction) of the ground
  26162. * * subdivisions the number of subdivisions per side
  26163. * * minHeight the minimum altitude on the ground, optional, default 0
  26164. * * maxHeight the maximum altitude on the ground, optional default 1
  26165. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26166. * * buffer the array holding the image color data
  26167. * * bufferWidth the width of image
  26168. * * bufferHeight the height of image
  26169. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26170. * @returns the VertexData of the Ground designed from a heightmap
  26171. */
  26172. static CreateGroundFromHeightMap(options: {
  26173. width: number;
  26174. height: number;
  26175. subdivisions: number;
  26176. minHeight: number;
  26177. maxHeight: number;
  26178. colorFilter: Color3;
  26179. buffer: Uint8Array;
  26180. bufferWidth: number;
  26181. bufferHeight: number;
  26182. alphaFilter: number;
  26183. }): VertexData;
  26184. /**
  26185. * Creates the VertexData for a Plane
  26186. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26187. * * size sets the width and height of the plane to the value of size, optional default 1
  26188. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26189. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26191. * * 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)
  26192. * * 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)
  26193. * @returns the VertexData of the box
  26194. */
  26195. static CreatePlane(options: {
  26196. size?: number;
  26197. width?: number;
  26198. height?: number;
  26199. sideOrientation?: number;
  26200. frontUVs?: Vector4;
  26201. backUVs?: Vector4;
  26202. }): VertexData;
  26203. /**
  26204. * Creates the VertexData of the Disc or regular Polygon
  26205. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26206. * * radius the radius of the disc, optional default 0.5
  26207. * * tessellation the number of polygon sides, optional, default 64
  26208. * * 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
  26209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26210. * * 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)
  26211. * * 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)
  26212. * @returns the VertexData of the box
  26213. */
  26214. static CreateDisc(options: {
  26215. radius?: number;
  26216. tessellation?: number;
  26217. arc?: number;
  26218. sideOrientation?: number;
  26219. frontUVs?: Vector4;
  26220. backUVs?: Vector4;
  26221. }): VertexData;
  26222. /**
  26223. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26224. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26225. * @param polygon a mesh built from polygonTriangulation.build()
  26226. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26227. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26228. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26229. * @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)
  26230. * @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)
  26231. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26232. * @returns the VertexData of the Polygon
  26233. */
  26234. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26235. /**
  26236. * Creates the VertexData of the IcoSphere
  26237. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26238. * * radius the radius of the IcoSphere, optional default 1
  26239. * * radiusX allows stretching in the x direction, optional, default radius
  26240. * * radiusY allows stretching in the y direction, optional, default radius
  26241. * * radiusZ allows stretching in the z direction, optional, default radius
  26242. * * flat when true creates a flat shaded mesh, optional, default true
  26243. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26245. * * 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)
  26246. * * 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)
  26247. * @returns the VertexData of the IcoSphere
  26248. */
  26249. static CreateIcoSphere(options: {
  26250. radius?: number;
  26251. radiusX?: number;
  26252. radiusY?: number;
  26253. radiusZ?: number;
  26254. flat?: boolean;
  26255. subdivisions?: number;
  26256. sideOrientation?: number;
  26257. frontUVs?: Vector4;
  26258. backUVs?: Vector4;
  26259. }): VertexData;
  26260. /**
  26261. * Creates the VertexData for a Polyhedron
  26262. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26263. * * type provided types are:
  26264. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26265. * * 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)
  26266. * * size the size of the IcoSphere, optional default 1
  26267. * * sizeX allows stretching in the x direction, optional, default size
  26268. * * sizeY allows stretching in the y direction, optional, default size
  26269. * * sizeZ allows stretching in the z direction, optional, default size
  26270. * * 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
  26271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26272. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26273. * * flat when true creates a flat shaded mesh, optional, default true
  26274. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26276. * * 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)
  26277. * * 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)
  26278. * @returns the VertexData of the Polyhedron
  26279. */
  26280. static CreatePolyhedron(options: {
  26281. type?: number;
  26282. size?: number;
  26283. sizeX?: number;
  26284. sizeY?: number;
  26285. sizeZ?: number;
  26286. custom?: any;
  26287. faceUV?: Vector4[];
  26288. faceColors?: Color4[];
  26289. flat?: boolean;
  26290. sideOrientation?: number;
  26291. frontUVs?: Vector4;
  26292. backUVs?: Vector4;
  26293. }): VertexData;
  26294. /**
  26295. * Creates the VertexData for a TorusKnot
  26296. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26297. * * radius the radius of the torus knot, optional, default 2
  26298. * * tube the thickness of the tube, optional, default 0.5
  26299. * * radialSegments the number of sides on each tube segments, optional, default 32
  26300. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26301. * * p the number of windings around the z axis, optional, default 2
  26302. * * q the number of windings around the x axis, optional, default 3
  26303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26304. * * 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)
  26305. * * 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)
  26306. * @returns the VertexData of the Torus Knot
  26307. */
  26308. static CreateTorusKnot(options: {
  26309. radius?: number;
  26310. tube?: number;
  26311. radialSegments?: number;
  26312. tubularSegments?: number;
  26313. p?: number;
  26314. q?: number;
  26315. sideOrientation?: number;
  26316. frontUVs?: Vector4;
  26317. backUVs?: Vector4;
  26318. }): VertexData;
  26319. /**
  26320. * Compute normals for given positions and indices
  26321. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26322. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26323. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26324. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26325. * * facetNormals : optional array of facet normals (vector3)
  26326. * * facetPositions : optional array of facet positions (vector3)
  26327. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26328. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26329. * * bInfo : optional bounding info, required for facetPartitioning computation
  26330. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26331. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26332. * * useRightHandedSystem: optional boolean to for right handed system computation
  26333. * * depthSort : optional boolean to enable the facet depth sort computation
  26334. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26335. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26336. */
  26337. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26338. facetNormals?: any;
  26339. facetPositions?: any;
  26340. facetPartitioning?: any;
  26341. ratio?: number;
  26342. bInfo?: any;
  26343. bbSize?: Vector3;
  26344. subDiv?: any;
  26345. useRightHandedSystem?: boolean;
  26346. depthSort?: boolean;
  26347. distanceTo?: Vector3;
  26348. depthSortedFacets?: any;
  26349. }): void;
  26350. /** @hidden */
  26351. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26352. /**
  26353. * Applies VertexData created from the imported parameters to the geometry
  26354. * @param parsedVertexData the parsed data from an imported file
  26355. * @param geometry the geometry to apply the VertexData to
  26356. */
  26357. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26358. }
  26359. }
  26360. declare module BABYLON {
  26361. /**
  26362. * Defines a target to use with MorphTargetManager
  26363. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26364. */
  26365. export class MorphTarget implements IAnimatable {
  26366. /** defines the name of the target */
  26367. name: string;
  26368. /**
  26369. * Gets or sets the list of animations
  26370. */
  26371. animations: Animation[];
  26372. private _scene;
  26373. private _positions;
  26374. private _normals;
  26375. private _tangents;
  26376. private _uvs;
  26377. private _influence;
  26378. private _uniqueId;
  26379. /**
  26380. * Observable raised when the influence changes
  26381. */
  26382. onInfluenceChanged: Observable<boolean>;
  26383. /** @hidden */
  26384. _onDataLayoutChanged: Observable<void>;
  26385. /**
  26386. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26387. */
  26388. get influence(): number;
  26389. set influence(influence: number);
  26390. /**
  26391. * Gets or sets the id of the morph Target
  26392. */
  26393. id: string;
  26394. private _animationPropertiesOverride;
  26395. /**
  26396. * Gets or sets the animation properties override
  26397. */
  26398. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26399. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26400. /**
  26401. * Creates a new MorphTarget
  26402. * @param name defines the name of the target
  26403. * @param influence defines the influence to use
  26404. * @param scene defines the scene the morphtarget belongs to
  26405. */
  26406. constructor(
  26407. /** defines the name of the target */
  26408. name: string, influence?: number, scene?: Nullable<Scene>);
  26409. /**
  26410. * Gets the unique ID of this manager
  26411. */
  26412. get uniqueId(): number;
  26413. /**
  26414. * Gets a boolean defining if the target contains position data
  26415. */
  26416. get hasPositions(): boolean;
  26417. /**
  26418. * Gets a boolean defining if the target contains normal data
  26419. */
  26420. get hasNormals(): boolean;
  26421. /**
  26422. * Gets a boolean defining if the target contains tangent data
  26423. */
  26424. get hasTangents(): boolean;
  26425. /**
  26426. * Gets a boolean defining if the target contains texture coordinates data
  26427. */
  26428. get hasUVs(): boolean;
  26429. /**
  26430. * Affects position data to this target
  26431. * @param data defines the position data to use
  26432. */
  26433. setPositions(data: Nullable<FloatArray>): void;
  26434. /**
  26435. * Gets the position data stored in this target
  26436. * @returns a FloatArray containing the position data (or null if not present)
  26437. */
  26438. getPositions(): Nullable<FloatArray>;
  26439. /**
  26440. * Affects normal data to this target
  26441. * @param data defines the normal data to use
  26442. */
  26443. setNormals(data: Nullable<FloatArray>): void;
  26444. /**
  26445. * Gets the normal data stored in this target
  26446. * @returns a FloatArray containing the normal data (or null if not present)
  26447. */
  26448. getNormals(): Nullable<FloatArray>;
  26449. /**
  26450. * Affects tangent data to this target
  26451. * @param data defines the tangent data to use
  26452. */
  26453. setTangents(data: Nullable<FloatArray>): void;
  26454. /**
  26455. * Gets the tangent data stored in this target
  26456. * @returns a FloatArray containing the tangent data (or null if not present)
  26457. */
  26458. getTangents(): Nullable<FloatArray>;
  26459. /**
  26460. * Affects texture coordinates data to this target
  26461. * @param data defines the texture coordinates data to use
  26462. */
  26463. setUVs(data: Nullable<FloatArray>): void;
  26464. /**
  26465. * Gets the texture coordinates data stored in this target
  26466. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26467. */
  26468. getUVs(): Nullable<FloatArray>;
  26469. /**
  26470. * Clone the current target
  26471. * @returns a new MorphTarget
  26472. */
  26473. clone(): MorphTarget;
  26474. /**
  26475. * Serializes the current target into a Serialization object
  26476. * @returns the serialized object
  26477. */
  26478. serialize(): any;
  26479. /**
  26480. * Returns the string "MorphTarget"
  26481. * @returns "MorphTarget"
  26482. */
  26483. getClassName(): string;
  26484. /**
  26485. * Creates a new target from serialized data
  26486. * @param serializationObject defines the serialized data to use
  26487. * @returns a new MorphTarget
  26488. */
  26489. static Parse(serializationObject: any): MorphTarget;
  26490. /**
  26491. * Creates a MorphTarget from mesh data
  26492. * @param mesh defines the source mesh
  26493. * @param name defines the name to use for the new target
  26494. * @param influence defines the influence to attach to the target
  26495. * @returns a new MorphTarget
  26496. */
  26497. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26498. }
  26499. }
  26500. declare module BABYLON {
  26501. /**
  26502. * This class is used to deform meshes using morphing between different targets
  26503. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26504. */
  26505. export class MorphTargetManager {
  26506. private _targets;
  26507. private _targetInfluenceChangedObservers;
  26508. private _targetDataLayoutChangedObservers;
  26509. private _activeTargets;
  26510. private _scene;
  26511. private _influences;
  26512. private _supportsNormals;
  26513. private _supportsTangents;
  26514. private _supportsUVs;
  26515. private _vertexCount;
  26516. private _uniqueId;
  26517. private _tempInfluences;
  26518. /**
  26519. * Gets or sets a boolean indicating if normals must be morphed
  26520. */
  26521. enableNormalMorphing: boolean;
  26522. /**
  26523. * Gets or sets a boolean indicating if tangents must be morphed
  26524. */
  26525. enableTangentMorphing: boolean;
  26526. /**
  26527. * Gets or sets a boolean indicating if UV must be morphed
  26528. */
  26529. enableUVMorphing: boolean;
  26530. /**
  26531. * Creates a new MorphTargetManager
  26532. * @param scene defines the current scene
  26533. */
  26534. constructor(scene?: Nullable<Scene>);
  26535. /**
  26536. * Gets the unique ID of this manager
  26537. */
  26538. get uniqueId(): number;
  26539. /**
  26540. * Gets the number of vertices handled by this manager
  26541. */
  26542. get vertexCount(): number;
  26543. /**
  26544. * Gets a boolean indicating if this manager supports morphing of normals
  26545. */
  26546. get supportsNormals(): boolean;
  26547. /**
  26548. * Gets a boolean indicating if this manager supports morphing of tangents
  26549. */
  26550. get supportsTangents(): boolean;
  26551. /**
  26552. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26553. */
  26554. get supportsUVs(): boolean;
  26555. /**
  26556. * Gets the number of targets stored in this manager
  26557. */
  26558. get numTargets(): number;
  26559. /**
  26560. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26561. */
  26562. get numInfluencers(): number;
  26563. /**
  26564. * Gets the list of influences (one per target)
  26565. */
  26566. get influences(): Float32Array;
  26567. /**
  26568. * Gets the active target at specified index. An active target is a target with an influence > 0
  26569. * @param index defines the index to check
  26570. * @returns the requested target
  26571. */
  26572. getActiveTarget(index: number): MorphTarget;
  26573. /**
  26574. * Gets the target at specified index
  26575. * @param index defines the index to check
  26576. * @returns the requested target
  26577. */
  26578. getTarget(index: number): MorphTarget;
  26579. /**
  26580. * Add a new target to this manager
  26581. * @param target defines the target to add
  26582. */
  26583. addTarget(target: MorphTarget): void;
  26584. /**
  26585. * Removes a target from the manager
  26586. * @param target defines the target to remove
  26587. */
  26588. removeTarget(target: MorphTarget): void;
  26589. /**
  26590. * Clone the current manager
  26591. * @returns a new MorphTargetManager
  26592. */
  26593. clone(): MorphTargetManager;
  26594. /**
  26595. * Serializes the current manager into a Serialization object
  26596. * @returns the serialized object
  26597. */
  26598. serialize(): any;
  26599. private _syncActiveTargets;
  26600. /**
  26601. * Syncrhonize the targets with all the meshes using this morph target manager
  26602. */
  26603. synchronize(): void;
  26604. /**
  26605. * Creates a new MorphTargetManager from serialized data
  26606. * @param serializationObject defines the serialized data
  26607. * @param scene defines the hosting scene
  26608. * @returns the new MorphTargetManager
  26609. */
  26610. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26611. }
  26612. }
  26613. declare module BABYLON {
  26614. /**
  26615. * Class used to represent a specific level of detail of a mesh
  26616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26617. */
  26618. export class MeshLODLevel {
  26619. /** Defines the distance where this level should start being displayed */
  26620. distance: number;
  26621. /** Defines the mesh to use to render this level */
  26622. mesh: Nullable<Mesh>;
  26623. /**
  26624. * Creates a new LOD level
  26625. * @param distance defines the distance where this level should star being displayed
  26626. * @param mesh defines the mesh to use to render this level
  26627. */
  26628. constructor(
  26629. /** Defines the distance where this level should start being displayed */
  26630. distance: number,
  26631. /** Defines the mesh to use to render this level */
  26632. mesh: Nullable<Mesh>);
  26633. }
  26634. }
  26635. declare module BABYLON {
  26636. /**
  26637. * Helper class used to generate a canvas to manipulate images
  26638. */
  26639. export class CanvasGenerator {
  26640. /**
  26641. * Create a new canvas (or offscreen canvas depending on the context)
  26642. * @param width defines the expected width
  26643. * @param height defines the expected height
  26644. * @return a new canvas or offscreen canvas
  26645. */
  26646. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26647. }
  26648. }
  26649. declare module BABYLON {
  26650. /**
  26651. * Mesh representing the gorund
  26652. */
  26653. export class GroundMesh extends Mesh {
  26654. /** If octree should be generated */
  26655. generateOctree: boolean;
  26656. private _heightQuads;
  26657. /** @hidden */
  26658. _subdivisionsX: number;
  26659. /** @hidden */
  26660. _subdivisionsY: number;
  26661. /** @hidden */
  26662. _width: number;
  26663. /** @hidden */
  26664. _height: number;
  26665. /** @hidden */
  26666. _minX: number;
  26667. /** @hidden */
  26668. _maxX: number;
  26669. /** @hidden */
  26670. _minZ: number;
  26671. /** @hidden */
  26672. _maxZ: number;
  26673. constructor(name: string, scene: Scene);
  26674. /**
  26675. * "GroundMesh"
  26676. * @returns "GroundMesh"
  26677. */
  26678. getClassName(): string;
  26679. /**
  26680. * The minimum of x and y subdivisions
  26681. */
  26682. get subdivisions(): number;
  26683. /**
  26684. * X subdivisions
  26685. */
  26686. get subdivisionsX(): number;
  26687. /**
  26688. * Y subdivisions
  26689. */
  26690. get subdivisionsY(): number;
  26691. /**
  26692. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26693. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26694. * @param chunksCount the number of subdivisions for x and y
  26695. * @param octreeBlocksSize (Default: 32)
  26696. */
  26697. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26698. /**
  26699. * Returns a height (y) value in the Worl system :
  26700. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26701. * @param x x coordinate
  26702. * @param z z coordinate
  26703. * @returns the ground y position if (x, z) are outside the ground surface.
  26704. */
  26705. getHeightAtCoordinates(x: number, z: number): number;
  26706. /**
  26707. * Returns a normalized vector (Vector3) orthogonal to the ground
  26708. * at the ground coordinates (x, z) expressed in the World system.
  26709. * @param x x coordinate
  26710. * @param z z coordinate
  26711. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26712. */
  26713. getNormalAtCoordinates(x: number, z: number): Vector3;
  26714. /**
  26715. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26716. * at the ground coordinates (x, z) expressed in the World system.
  26717. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26718. * @param x x coordinate
  26719. * @param z z coordinate
  26720. * @param ref vector to store the result
  26721. * @returns the GroundMesh.
  26722. */
  26723. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26724. /**
  26725. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26726. * if the ground has been updated.
  26727. * This can be used in the render loop.
  26728. * @returns the GroundMesh.
  26729. */
  26730. updateCoordinateHeights(): GroundMesh;
  26731. private _getFacetAt;
  26732. private _initHeightQuads;
  26733. private _computeHeightQuads;
  26734. /**
  26735. * Serializes this ground mesh
  26736. * @param serializationObject object to write serialization to
  26737. */
  26738. serialize(serializationObject: any): void;
  26739. /**
  26740. * Parses a serialized ground mesh
  26741. * @param parsedMesh the serialized mesh
  26742. * @param scene the scene to create the ground mesh in
  26743. * @returns the created ground mesh
  26744. */
  26745. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26746. }
  26747. }
  26748. declare module BABYLON {
  26749. /**
  26750. * Interface for Physics-Joint data
  26751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26752. */
  26753. export interface PhysicsJointData {
  26754. /**
  26755. * The main pivot of the joint
  26756. */
  26757. mainPivot?: Vector3;
  26758. /**
  26759. * The connected pivot of the joint
  26760. */
  26761. connectedPivot?: Vector3;
  26762. /**
  26763. * The main axis of the joint
  26764. */
  26765. mainAxis?: Vector3;
  26766. /**
  26767. * The connected axis of the joint
  26768. */
  26769. connectedAxis?: Vector3;
  26770. /**
  26771. * The collision of the joint
  26772. */
  26773. collision?: boolean;
  26774. /**
  26775. * Native Oimo/Cannon/Energy data
  26776. */
  26777. nativeParams?: any;
  26778. }
  26779. /**
  26780. * This is a holder class for the physics joint created by the physics plugin
  26781. * It holds a set of functions to control the underlying joint
  26782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26783. */
  26784. export class PhysicsJoint {
  26785. /**
  26786. * The type of the physics joint
  26787. */
  26788. type: number;
  26789. /**
  26790. * The data for the physics joint
  26791. */
  26792. jointData: PhysicsJointData;
  26793. private _physicsJoint;
  26794. protected _physicsPlugin: IPhysicsEnginePlugin;
  26795. /**
  26796. * Initializes the physics joint
  26797. * @param type The type of the physics joint
  26798. * @param jointData The data for the physics joint
  26799. */
  26800. constructor(
  26801. /**
  26802. * The type of the physics joint
  26803. */
  26804. type: number,
  26805. /**
  26806. * The data for the physics joint
  26807. */
  26808. jointData: PhysicsJointData);
  26809. /**
  26810. * Gets the physics joint
  26811. */
  26812. get physicsJoint(): any;
  26813. /**
  26814. * Sets the physics joint
  26815. */
  26816. set physicsJoint(newJoint: any);
  26817. /**
  26818. * Sets the physics plugin
  26819. */
  26820. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26821. /**
  26822. * Execute a function that is physics-plugin specific.
  26823. * @param {Function} func the function that will be executed.
  26824. * It accepts two parameters: the physics world and the physics joint
  26825. */
  26826. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26827. /**
  26828. * Distance-Joint type
  26829. */
  26830. static DistanceJoint: number;
  26831. /**
  26832. * Hinge-Joint type
  26833. */
  26834. static HingeJoint: number;
  26835. /**
  26836. * Ball-and-Socket joint type
  26837. */
  26838. static BallAndSocketJoint: number;
  26839. /**
  26840. * Wheel-Joint type
  26841. */
  26842. static WheelJoint: number;
  26843. /**
  26844. * Slider-Joint type
  26845. */
  26846. static SliderJoint: number;
  26847. /**
  26848. * Prismatic-Joint type
  26849. */
  26850. static PrismaticJoint: number;
  26851. /**
  26852. * Universal-Joint type
  26853. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26854. */
  26855. static UniversalJoint: number;
  26856. /**
  26857. * Hinge-Joint 2 type
  26858. */
  26859. static Hinge2Joint: number;
  26860. /**
  26861. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26862. */
  26863. static PointToPointJoint: number;
  26864. /**
  26865. * Spring-Joint type
  26866. */
  26867. static SpringJoint: number;
  26868. /**
  26869. * Lock-Joint type
  26870. */
  26871. static LockJoint: number;
  26872. }
  26873. /**
  26874. * A class representing a physics distance joint
  26875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26876. */
  26877. export class DistanceJoint extends PhysicsJoint {
  26878. /**
  26879. *
  26880. * @param jointData The data for the Distance-Joint
  26881. */
  26882. constructor(jointData: DistanceJointData);
  26883. /**
  26884. * Update the predefined distance.
  26885. * @param maxDistance The maximum preferred distance
  26886. * @param minDistance The minimum preferred distance
  26887. */
  26888. updateDistance(maxDistance: number, minDistance?: number): void;
  26889. }
  26890. /**
  26891. * Represents a Motor-Enabled Joint
  26892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26893. */
  26894. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26895. /**
  26896. * Initializes the Motor-Enabled Joint
  26897. * @param type The type of the joint
  26898. * @param jointData The physica joint data for the joint
  26899. */
  26900. constructor(type: number, jointData: PhysicsJointData);
  26901. /**
  26902. * Set the motor values.
  26903. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26904. * @param force the force to apply
  26905. * @param maxForce max force for this motor.
  26906. */
  26907. setMotor(force?: number, maxForce?: number): void;
  26908. /**
  26909. * Set the motor's limits.
  26910. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26911. * @param upperLimit The upper limit of the motor
  26912. * @param lowerLimit The lower limit of the motor
  26913. */
  26914. setLimit(upperLimit: number, lowerLimit?: number): void;
  26915. }
  26916. /**
  26917. * This class represents a single physics Hinge-Joint
  26918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26919. */
  26920. export class HingeJoint extends MotorEnabledJoint {
  26921. /**
  26922. * Initializes the Hinge-Joint
  26923. * @param jointData The joint data for the Hinge-Joint
  26924. */
  26925. constructor(jointData: PhysicsJointData);
  26926. /**
  26927. * Set the motor values.
  26928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26929. * @param {number} force the force to apply
  26930. * @param {number} maxForce max force for this motor.
  26931. */
  26932. setMotor(force?: number, maxForce?: number): void;
  26933. /**
  26934. * Set the motor's limits.
  26935. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26936. * @param upperLimit The upper limit of the motor
  26937. * @param lowerLimit The lower limit of the motor
  26938. */
  26939. setLimit(upperLimit: number, lowerLimit?: number): void;
  26940. }
  26941. /**
  26942. * This class represents a dual hinge physics joint (same as wheel joint)
  26943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26944. */
  26945. export class Hinge2Joint extends MotorEnabledJoint {
  26946. /**
  26947. * Initializes the Hinge2-Joint
  26948. * @param jointData The joint data for the Hinge2-Joint
  26949. */
  26950. constructor(jointData: PhysicsJointData);
  26951. /**
  26952. * Set the motor values.
  26953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26954. * @param {number} targetSpeed the speed the motor is to reach
  26955. * @param {number} maxForce max force for this motor.
  26956. * @param {motorIndex} the motor's index, 0 or 1.
  26957. */
  26958. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26959. /**
  26960. * Set the motor limits.
  26961. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26962. * @param {number} upperLimit the upper limit
  26963. * @param {number} lowerLimit lower limit
  26964. * @param {motorIndex} the motor's index, 0 or 1.
  26965. */
  26966. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26967. }
  26968. /**
  26969. * Interface for a motor enabled joint
  26970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26971. */
  26972. export interface IMotorEnabledJoint {
  26973. /**
  26974. * Physics joint
  26975. */
  26976. physicsJoint: any;
  26977. /**
  26978. * Sets the motor of the motor-enabled joint
  26979. * @param force The force of the motor
  26980. * @param maxForce The maximum force of the motor
  26981. * @param motorIndex The index of the motor
  26982. */
  26983. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26984. /**
  26985. * Sets the limit of the motor
  26986. * @param upperLimit The upper limit of the motor
  26987. * @param lowerLimit The lower limit of the motor
  26988. * @param motorIndex The index of the motor
  26989. */
  26990. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26991. }
  26992. /**
  26993. * Joint data for a Distance-Joint
  26994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26995. */
  26996. export interface DistanceJointData extends PhysicsJointData {
  26997. /**
  26998. * Max distance the 2 joint objects can be apart
  26999. */
  27000. maxDistance: number;
  27001. }
  27002. /**
  27003. * Joint data from a spring joint
  27004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27005. */
  27006. export interface SpringJointData extends PhysicsJointData {
  27007. /**
  27008. * Length of the spring
  27009. */
  27010. length: number;
  27011. /**
  27012. * Stiffness of the spring
  27013. */
  27014. stiffness: number;
  27015. /**
  27016. * Damping of the spring
  27017. */
  27018. damping: number;
  27019. /** this callback will be called when applying the force to the impostors. */
  27020. forceApplicationCallback: () => void;
  27021. }
  27022. }
  27023. declare module BABYLON {
  27024. /**
  27025. * Holds the data for the raycast result
  27026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27027. */
  27028. export class PhysicsRaycastResult {
  27029. private _hasHit;
  27030. private _hitDistance;
  27031. private _hitNormalWorld;
  27032. private _hitPointWorld;
  27033. private _rayFromWorld;
  27034. private _rayToWorld;
  27035. /**
  27036. * Gets if there was a hit
  27037. */
  27038. get hasHit(): boolean;
  27039. /**
  27040. * Gets the distance from the hit
  27041. */
  27042. get hitDistance(): number;
  27043. /**
  27044. * Gets the hit normal/direction in the world
  27045. */
  27046. get hitNormalWorld(): Vector3;
  27047. /**
  27048. * Gets the hit point in the world
  27049. */
  27050. get hitPointWorld(): Vector3;
  27051. /**
  27052. * Gets the ray "start point" of the ray in the world
  27053. */
  27054. get rayFromWorld(): Vector3;
  27055. /**
  27056. * Gets the ray "end point" of the ray in the world
  27057. */
  27058. get rayToWorld(): Vector3;
  27059. /**
  27060. * Sets the hit data (normal & point in world space)
  27061. * @param hitNormalWorld defines the normal in world space
  27062. * @param hitPointWorld defines the point in world space
  27063. */
  27064. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27065. /**
  27066. * Sets the distance from the start point to the hit point
  27067. * @param distance
  27068. */
  27069. setHitDistance(distance: number): void;
  27070. /**
  27071. * Calculates the distance manually
  27072. */
  27073. calculateHitDistance(): void;
  27074. /**
  27075. * Resets all the values to default
  27076. * @param from The from point on world space
  27077. * @param to The to point on world space
  27078. */
  27079. reset(from?: Vector3, to?: Vector3): void;
  27080. }
  27081. /**
  27082. * Interface for the size containing width and height
  27083. */
  27084. interface IXYZ {
  27085. /**
  27086. * X
  27087. */
  27088. x: number;
  27089. /**
  27090. * Y
  27091. */
  27092. y: number;
  27093. /**
  27094. * Z
  27095. */
  27096. z: number;
  27097. }
  27098. }
  27099. declare module BABYLON {
  27100. /**
  27101. * Interface used to describe a physics joint
  27102. */
  27103. export interface PhysicsImpostorJoint {
  27104. /** Defines the main impostor to which the joint is linked */
  27105. mainImpostor: PhysicsImpostor;
  27106. /** Defines the impostor that is connected to the main impostor using this joint */
  27107. connectedImpostor: PhysicsImpostor;
  27108. /** Defines the joint itself */
  27109. joint: PhysicsJoint;
  27110. }
  27111. /** @hidden */
  27112. export interface IPhysicsEnginePlugin {
  27113. world: any;
  27114. name: string;
  27115. setGravity(gravity: Vector3): void;
  27116. setTimeStep(timeStep: number): void;
  27117. getTimeStep(): number;
  27118. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27119. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27120. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27121. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27122. removePhysicsBody(impostor: PhysicsImpostor): void;
  27123. generateJoint(joint: PhysicsImpostorJoint): void;
  27124. removeJoint(joint: PhysicsImpostorJoint): void;
  27125. isSupported(): boolean;
  27126. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27127. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27128. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27129. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27130. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27131. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27132. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27133. getBodyMass(impostor: PhysicsImpostor): number;
  27134. getBodyFriction(impostor: PhysicsImpostor): number;
  27135. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27136. getBodyRestitution(impostor: PhysicsImpostor): number;
  27137. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27138. getBodyPressure?(impostor: PhysicsImpostor): number;
  27139. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27140. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27141. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27142. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27143. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27144. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27145. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27146. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27147. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27148. sleepBody(impostor: PhysicsImpostor): void;
  27149. wakeUpBody(impostor: PhysicsImpostor): void;
  27150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27151. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27152. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27153. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27154. getRadius(impostor: PhysicsImpostor): number;
  27155. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27157. dispose(): void;
  27158. }
  27159. /**
  27160. * Interface used to define a physics engine
  27161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27162. */
  27163. export interface IPhysicsEngine {
  27164. /**
  27165. * Gets the gravity vector used by the simulation
  27166. */
  27167. gravity: Vector3;
  27168. /**
  27169. * Sets the gravity vector used by the simulation
  27170. * @param gravity defines the gravity vector to use
  27171. */
  27172. setGravity(gravity: Vector3): void;
  27173. /**
  27174. * Set the time step of the physics engine.
  27175. * Default is 1/60.
  27176. * To slow it down, enter 1/600 for example.
  27177. * To speed it up, 1/30
  27178. * @param newTimeStep the new timestep to apply to this world.
  27179. */
  27180. setTimeStep(newTimeStep: number): void;
  27181. /**
  27182. * Get the time step of the physics engine.
  27183. * @returns the current time step
  27184. */
  27185. getTimeStep(): number;
  27186. /**
  27187. * Set the sub time step of the physics engine.
  27188. * Default is 0 meaning there is no sub steps
  27189. * To increase physics resolution precision, set a small value (like 1 ms)
  27190. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27191. */
  27192. setSubTimeStep(subTimeStep: number): void;
  27193. /**
  27194. * Get the sub time step of the physics engine.
  27195. * @returns the current sub time step
  27196. */
  27197. getSubTimeStep(): number;
  27198. /**
  27199. * Release all resources
  27200. */
  27201. dispose(): void;
  27202. /**
  27203. * Gets the name of the current physics plugin
  27204. * @returns the name of the plugin
  27205. */
  27206. getPhysicsPluginName(): string;
  27207. /**
  27208. * Adding a new impostor for the impostor tracking.
  27209. * This will be done by the impostor itself.
  27210. * @param impostor the impostor to add
  27211. */
  27212. addImpostor(impostor: PhysicsImpostor): void;
  27213. /**
  27214. * Remove an impostor from the engine.
  27215. * This impostor and its mesh will not longer be updated by the physics engine.
  27216. * @param impostor the impostor to remove
  27217. */
  27218. removeImpostor(impostor: PhysicsImpostor): void;
  27219. /**
  27220. * Add a joint to the physics engine
  27221. * @param mainImpostor defines the main impostor to which the joint is added.
  27222. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27223. * @param joint defines the joint that will connect both impostors.
  27224. */
  27225. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27226. /**
  27227. * Removes a joint from the simulation
  27228. * @param mainImpostor defines the impostor used with the joint
  27229. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27230. * @param joint defines the joint to remove
  27231. */
  27232. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27233. /**
  27234. * Gets the current plugin used to run the simulation
  27235. * @returns current plugin
  27236. */
  27237. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27238. /**
  27239. * Gets the list of physic impostors
  27240. * @returns an array of PhysicsImpostor
  27241. */
  27242. getImpostors(): Array<PhysicsImpostor>;
  27243. /**
  27244. * Gets the impostor for a physics enabled object
  27245. * @param object defines the object impersonated by the impostor
  27246. * @returns the PhysicsImpostor or null if not found
  27247. */
  27248. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27249. /**
  27250. * Gets the impostor for a physics body object
  27251. * @param body defines physics body used by the impostor
  27252. * @returns the PhysicsImpostor or null if not found
  27253. */
  27254. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27255. /**
  27256. * Does a raycast in the physics world
  27257. * @param from when should the ray start?
  27258. * @param to when should the ray end?
  27259. * @returns PhysicsRaycastResult
  27260. */
  27261. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27262. /**
  27263. * Called by the scene. No need to call it.
  27264. * @param delta defines the timespam between frames
  27265. */
  27266. _step(delta: number): void;
  27267. }
  27268. }
  27269. declare module BABYLON {
  27270. /**
  27271. * The interface for the physics imposter parameters
  27272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27273. */
  27274. export interface PhysicsImpostorParameters {
  27275. /**
  27276. * The mass of the physics imposter
  27277. */
  27278. mass: number;
  27279. /**
  27280. * The friction of the physics imposter
  27281. */
  27282. friction?: number;
  27283. /**
  27284. * The coefficient of restitution of the physics imposter
  27285. */
  27286. restitution?: number;
  27287. /**
  27288. * The native options of the physics imposter
  27289. */
  27290. nativeOptions?: any;
  27291. /**
  27292. * Specifies if the parent should be ignored
  27293. */
  27294. ignoreParent?: boolean;
  27295. /**
  27296. * Specifies if bi-directional transformations should be disabled
  27297. */
  27298. disableBidirectionalTransformation?: boolean;
  27299. /**
  27300. * The pressure inside the physics imposter, soft object only
  27301. */
  27302. pressure?: number;
  27303. /**
  27304. * The stiffness the physics imposter, soft object only
  27305. */
  27306. stiffness?: number;
  27307. /**
  27308. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27309. */
  27310. velocityIterations?: number;
  27311. /**
  27312. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27313. */
  27314. positionIterations?: number;
  27315. /**
  27316. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27317. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27318. * Add to fix multiple points
  27319. */
  27320. fixedPoints?: number;
  27321. /**
  27322. * The collision margin around a soft object
  27323. */
  27324. margin?: number;
  27325. /**
  27326. * The collision margin around a soft object
  27327. */
  27328. damping?: number;
  27329. /**
  27330. * The path for a rope based on an extrusion
  27331. */
  27332. path?: any;
  27333. /**
  27334. * The shape of an extrusion used for a rope based on an extrusion
  27335. */
  27336. shape?: any;
  27337. }
  27338. /**
  27339. * Interface for a physics-enabled object
  27340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27341. */
  27342. export interface IPhysicsEnabledObject {
  27343. /**
  27344. * The position of the physics-enabled object
  27345. */
  27346. position: Vector3;
  27347. /**
  27348. * The rotation of the physics-enabled object
  27349. */
  27350. rotationQuaternion: Nullable<Quaternion>;
  27351. /**
  27352. * The scale of the physics-enabled object
  27353. */
  27354. scaling: Vector3;
  27355. /**
  27356. * The rotation of the physics-enabled object
  27357. */
  27358. rotation?: Vector3;
  27359. /**
  27360. * The parent of the physics-enabled object
  27361. */
  27362. parent?: any;
  27363. /**
  27364. * The bounding info of the physics-enabled object
  27365. * @returns The bounding info of the physics-enabled object
  27366. */
  27367. getBoundingInfo(): BoundingInfo;
  27368. /**
  27369. * Computes the world matrix
  27370. * @param force Specifies if the world matrix should be computed by force
  27371. * @returns A world matrix
  27372. */
  27373. computeWorldMatrix(force: boolean): Matrix;
  27374. /**
  27375. * Gets the world matrix
  27376. * @returns A world matrix
  27377. */
  27378. getWorldMatrix?(): Matrix;
  27379. /**
  27380. * Gets the child meshes
  27381. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27382. * @returns An array of abstract meshes
  27383. */
  27384. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27385. /**
  27386. * Gets the vertex data
  27387. * @param kind The type of vertex data
  27388. * @returns A nullable array of numbers, or a float32 array
  27389. */
  27390. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27391. /**
  27392. * Gets the indices from the mesh
  27393. * @returns A nullable array of index arrays
  27394. */
  27395. getIndices?(): Nullable<IndicesArray>;
  27396. /**
  27397. * Gets the scene from the mesh
  27398. * @returns the indices array or null
  27399. */
  27400. getScene?(): Scene;
  27401. /**
  27402. * Gets the absolute position from the mesh
  27403. * @returns the absolute position
  27404. */
  27405. getAbsolutePosition(): Vector3;
  27406. /**
  27407. * Gets the absolute pivot point from the mesh
  27408. * @returns the absolute pivot point
  27409. */
  27410. getAbsolutePivotPoint(): Vector3;
  27411. /**
  27412. * Rotates the mesh
  27413. * @param axis The axis of rotation
  27414. * @param amount The amount of rotation
  27415. * @param space The space of the rotation
  27416. * @returns The rotation transform node
  27417. */
  27418. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27419. /**
  27420. * Translates the mesh
  27421. * @param axis The axis of translation
  27422. * @param distance The distance of translation
  27423. * @param space The space of the translation
  27424. * @returns The transform node
  27425. */
  27426. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27427. /**
  27428. * Sets the absolute position of the mesh
  27429. * @param absolutePosition The absolute position of the mesh
  27430. * @returns The transform node
  27431. */
  27432. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27433. /**
  27434. * Gets the class name of the mesh
  27435. * @returns The class name
  27436. */
  27437. getClassName(): string;
  27438. }
  27439. /**
  27440. * Represents a physics imposter
  27441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27442. */
  27443. export class PhysicsImpostor {
  27444. /**
  27445. * The physics-enabled object used as the physics imposter
  27446. */
  27447. object: IPhysicsEnabledObject;
  27448. /**
  27449. * The type of the physics imposter
  27450. */
  27451. type: number;
  27452. private _options;
  27453. private _scene?;
  27454. /**
  27455. * The default object size of the imposter
  27456. */
  27457. static DEFAULT_OBJECT_SIZE: Vector3;
  27458. /**
  27459. * The identity quaternion of the imposter
  27460. */
  27461. static IDENTITY_QUATERNION: Quaternion;
  27462. /** @hidden */
  27463. _pluginData: any;
  27464. private _physicsEngine;
  27465. private _physicsBody;
  27466. private _bodyUpdateRequired;
  27467. private _onBeforePhysicsStepCallbacks;
  27468. private _onAfterPhysicsStepCallbacks;
  27469. /** @hidden */
  27470. _onPhysicsCollideCallbacks: Array<{
  27471. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27472. otherImpostors: Array<PhysicsImpostor>;
  27473. }>;
  27474. private _deltaPosition;
  27475. private _deltaRotation;
  27476. private _deltaRotationConjugated;
  27477. /** @hidden */
  27478. _isFromLine: boolean;
  27479. private _parent;
  27480. private _isDisposed;
  27481. private static _tmpVecs;
  27482. private static _tmpQuat;
  27483. /**
  27484. * Specifies if the physics imposter is disposed
  27485. */
  27486. get isDisposed(): boolean;
  27487. /**
  27488. * Gets the mass of the physics imposter
  27489. */
  27490. get mass(): number;
  27491. set mass(value: number);
  27492. /**
  27493. * Gets the coefficient of friction
  27494. */
  27495. get friction(): number;
  27496. /**
  27497. * Sets the coefficient of friction
  27498. */
  27499. set friction(value: number);
  27500. /**
  27501. * Gets the coefficient of restitution
  27502. */
  27503. get restitution(): number;
  27504. /**
  27505. * Sets the coefficient of restitution
  27506. */
  27507. set restitution(value: number);
  27508. /**
  27509. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27510. */
  27511. get pressure(): number;
  27512. /**
  27513. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27514. */
  27515. set pressure(value: number);
  27516. /**
  27517. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27518. */
  27519. get stiffness(): number;
  27520. /**
  27521. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27522. */
  27523. set stiffness(value: number);
  27524. /**
  27525. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27526. */
  27527. get velocityIterations(): number;
  27528. /**
  27529. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27530. */
  27531. set velocityIterations(value: number);
  27532. /**
  27533. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27534. */
  27535. get positionIterations(): number;
  27536. /**
  27537. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27538. */
  27539. set positionIterations(value: number);
  27540. /**
  27541. * The unique id of the physics imposter
  27542. * set by the physics engine when adding this impostor to the array
  27543. */
  27544. uniqueId: number;
  27545. /**
  27546. * @hidden
  27547. */
  27548. soft: boolean;
  27549. /**
  27550. * @hidden
  27551. */
  27552. segments: number;
  27553. private _joints;
  27554. /**
  27555. * Initializes the physics imposter
  27556. * @param object The physics-enabled object used as the physics imposter
  27557. * @param type The type of the physics imposter
  27558. * @param _options The options for the physics imposter
  27559. * @param _scene The Babylon scene
  27560. */
  27561. constructor(
  27562. /**
  27563. * The physics-enabled object used as the physics imposter
  27564. */
  27565. object: IPhysicsEnabledObject,
  27566. /**
  27567. * The type of the physics imposter
  27568. */
  27569. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27570. /**
  27571. * This function will completly initialize this impostor.
  27572. * It will create a new body - but only if this mesh has no parent.
  27573. * If it has, this impostor will not be used other than to define the impostor
  27574. * of the child mesh.
  27575. * @hidden
  27576. */
  27577. _init(): void;
  27578. private _getPhysicsParent;
  27579. /**
  27580. * Should a new body be generated.
  27581. * @returns boolean specifying if body initialization is required
  27582. */
  27583. isBodyInitRequired(): boolean;
  27584. /**
  27585. * Sets the updated scaling
  27586. * @param updated Specifies if the scaling is updated
  27587. */
  27588. setScalingUpdated(): void;
  27589. /**
  27590. * Force a regeneration of this or the parent's impostor's body.
  27591. * Use under cautious - This will remove all joints already implemented.
  27592. */
  27593. forceUpdate(): void;
  27594. /**
  27595. * Gets the body that holds this impostor. Either its own, or its parent.
  27596. */
  27597. get physicsBody(): any;
  27598. /**
  27599. * Get the parent of the physics imposter
  27600. * @returns Physics imposter or null
  27601. */
  27602. get parent(): Nullable<PhysicsImpostor>;
  27603. /**
  27604. * Sets the parent of the physics imposter
  27605. */
  27606. set parent(value: Nullable<PhysicsImpostor>);
  27607. /**
  27608. * Set the physics body. Used mainly by the physics engine/plugin
  27609. */
  27610. set physicsBody(physicsBody: any);
  27611. /**
  27612. * Resets the update flags
  27613. */
  27614. resetUpdateFlags(): void;
  27615. /**
  27616. * Gets the object extend size
  27617. * @returns the object extend size
  27618. */
  27619. getObjectExtendSize(): Vector3;
  27620. /**
  27621. * Gets the object center
  27622. * @returns The object center
  27623. */
  27624. getObjectCenter(): Vector3;
  27625. /**
  27626. * Get a specific parameter from the options parameters
  27627. * @param paramName The object parameter name
  27628. * @returns The object parameter
  27629. */
  27630. getParam(paramName: string): any;
  27631. /**
  27632. * Sets a specific parameter in the options given to the physics plugin
  27633. * @param paramName The parameter name
  27634. * @param value The value of the parameter
  27635. */
  27636. setParam(paramName: string, value: number): void;
  27637. /**
  27638. * Specifically change the body's mass option. Won't recreate the physics body object
  27639. * @param mass The mass of the physics imposter
  27640. */
  27641. setMass(mass: number): void;
  27642. /**
  27643. * Gets the linear velocity
  27644. * @returns linear velocity or null
  27645. */
  27646. getLinearVelocity(): Nullable<Vector3>;
  27647. /**
  27648. * Sets the linear velocity
  27649. * @param velocity linear velocity or null
  27650. */
  27651. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27652. /**
  27653. * Gets the angular velocity
  27654. * @returns angular velocity or null
  27655. */
  27656. getAngularVelocity(): Nullable<Vector3>;
  27657. /**
  27658. * Sets the angular velocity
  27659. * @param velocity The velocity or null
  27660. */
  27661. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27662. /**
  27663. * Execute a function with the physics plugin native code
  27664. * Provide a function the will have two variables - the world object and the physics body object
  27665. * @param func The function to execute with the physics plugin native code
  27666. */
  27667. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27668. /**
  27669. * Register a function that will be executed before the physics world is stepping forward
  27670. * @param func The function to execute before the physics world is stepped forward
  27671. */
  27672. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27673. /**
  27674. * Unregister a function that will be executed before the physics world is stepping forward
  27675. * @param func The function to execute before the physics world is stepped forward
  27676. */
  27677. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27678. /**
  27679. * Register a function that will be executed after the physics step
  27680. * @param func The function to execute after physics step
  27681. */
  27682. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27683. /**
  27684. * Unregisters a function that will be executed after the physics step
  27685. * @param func The function to execute after physics step
  27686. */
  27687. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27688. /**
  27689. * register a function that will be executed when this impostor collides against a different body
  27690. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27691. * @param func Callback that is executed on collision
  27692. */
  27693. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27694. /**
  27695. * Unregisters the physics imposter on contact
  27696. * @param collideAgainst The physics object to collide against
  27697. * @param func Callback to execute on collision
  27698. */
  27699. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27700. private _tmpQuat;
  27701. private _tmpQuat2;
  27702. /**
  27703. * Get the parent rotation
  27704. * @returns The parent rotation
  27705. */
  27706. getParentsRotation(): Quaternion;
  27707. /**
  27708. * this function is executed by the physics engine.
  27709. */
  27710. beforeStep: () => void;
  27711. /**
  27712. * this function is executed by the physics engine
  27713. */
  27714. afterStep: () => void;
  27715. /**
  27716. * Legacy collision detection event support
  27717. */
  27718. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27719. /**
  27720. * event and body object due to cannon's event-based architecture.
  27721. */
  27722. onCollide: (e: {
  27723. body: any;
  27724. }) => void;
  27725. /**
  27726. * Apply a force
  27727. * @param force The force to apply
  27728. * @param contactPoint The contact point for the force
  27729. * @returns The physics imposter
  27730. */
  27731. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27732. /**
  27733. * Apply an impulse
  27734. * @param force The impulse force
  27735. * @param contactPoint The contact point for the impulse force
  27736. * @returns The physics imposter
  27737. */
  27738. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27739. /**
  27740. * A help function to create a joint
  27741. * @param otherImpostor A physics imposter used to create a joint
  27742. * @param jointType The type of joint
  27743. * @param jointData The data for the joint
  27744. * @returns The physics imposter
  27745. */
  27746. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27747. /**
  27748. * Add a joint to this impostor with a different impostor
  27749. * @param otherImpostor A physics imposter used to add a joint
  27750. * @param joint The joint to add
  27751. * @returns The physics imposter
  27752. */
  27753. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27754. /**
  27755. * Add an anchor to a cloth impostor
  27756. * @param otherImpostor rigid impostor to anchor to
  27757. * @param width ratio across width from 0 to 1
  27758. * @param height ratio up height from 0 to 1
  27759. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27760. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27761. * @returns impostor the soft imposter
  27762. */
  27763. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27764. /**
  27765. * Add a hook to a rope impostor
  27766. * @param otherImpostor rigid impostor to anchor to
  27767. * @param length ratio across rope from 0 to 1
  27768. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27769. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27770. * @returns impostor the rope imposter
  27771. */
  27772. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27773. /**
  27774. * Will keep this body still, in a sleep mode.
  27775. * @returns the physics imposter
  27776. */
  27777. sleep(): PhysicsImpostor;
  27778. /**
  27779. * Wake the body up.
  27780. * @returns The physics imposter
  27781. */
  27782. wakeUp(): PhysicsImpostor;
  27783. /**
  27784. * Clones the physics imposter
  27785. * @param newObject The physics imposter clones to this physics-enabled object
  27786. * @returns A nullable physics imposter
  27787. */
  27788. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27789. /**
  27790. * Disposes the physics imposter
  27791. */
  27792. dispose(): void;
  27793. /**
  27794. * Sets the delta position
  27795. * @param position The delta position amount
  27796. */
  27797. setDeltaPosition(position: Vector3): void;
  27798. /**
  27799. * Sets the delta rotation
  27800. * @param rotation The delta rotation amount
  27801. */
  27802. setDeltaRotation(rotation: Quaternion): void;
  27803. /**
  27804. * Gets the box size of the physics imposter and stores the result in the input parameter
  27805. * @param result Stores the box size
  27806. * @returns The physics imposter
  27807. */
  27808. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27809. /**
  27810. * Gets the radius of the physics imposter
  27811. * @returns Radius of the physics imposter
  27812. */
  27813. getRadius(): number;
  27814. /**
  27815. * Sync a bone with this impostor
  27816. * @param bone The bone to sync to the impostor.
  27817. * @param boneMesh The mesh that the bone is influencing.
  27818. * @param jointPivot The pivot of the joint / bone in local space.
  27819. * @param distToJoint Optional distance from the impostor to the joint.
  27820. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27821. */
  27822. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27823. /**
  27824. * Sync impostor to a bone
  27825. * @param bone The bone that the impostor will be synced to.
  27826. * @param boneMesh The mesh that the bone is influencing.
  27827. * @param jointPivot The pivot of the joint / bone in local space.
  27828. * @param distToJoint Optional distance from the impostor to the joint.
  27829. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27830. * @param boneAxis Optional vector3 axis the bone is aligned with
  27831. */
  27832. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27833. /**
  27834. * No-Imposter type
  27835. */
  27836. static NoImpostor: number;
  27837. /**
  27838. * Sphere-Imposter type
  27839. */
  27840. static SphereImpostor: number;
  27841. /**
  27842. * Box-Imposter type
  27843. */
  27844. static BoxImpostor: number;
  27845. /**
  27846. * Plane-Imposter type
  27847. */
  27848. static PlaneImpostor: number;
  27849. /**
  27850. * Mesh-imposter type
  27851. */
  27852. static MeshImpostor: number;
  27853. /**
  27854. * Capsule-Impostor type (Ammo.js plugin only)
  27855. */
  27856. static CapsuleImpostor: number;
  27857. /**
  27858. * Cylinder-Imposter type
  27859. */
  27860. static CylinderImpostor: number;
  27861. /**
  27862. * Particle-Imposter type
  27863. */
  27864. static ParticleImpostor: number;
  27865. /**
  27866. * Heightmap-Imposter type
  27867. */
  27868. static HeightmapImpostor: number;
  27869. /**
  27870. * ConvexHull-Impostor type (Ammo.js plugin only)
  27871. */
  27872. static ConvexHullImpostor: number;
  27873. /**
  27874. * Custom-Imposter type (Ammo.js plugin only)
  27875. */
  27876. static CustomImpostor: number;
  27877. /**
  27878. * Rope-Imposter type
  27879. */
  27880. static RopeImpostor: number;
  27881. /**
  27882. * Cloth-Imposter type
  27883. */
  27884. static ClothImpostor: number;
  27885. /**
  27886. * Softbody-Imposter type
  27887. */
  27888. static SoftbodyImpostor: number;
  27889. }
  27890. }
  27891. declare module BABYLON {
  27892. /**
  27893. * @hidden
  27894. **/
  27895. export class _CreationDataStorage {
  27896. closePath?: boolean;
  27897. closeArray?: boolean;
  27898. idx: number[];
  27899. dashSize: number;
  27900. gapSize: number;
  27901. path3D: Path3D;
  27902. pathArray: Vector3[][];
  27903. arc: number;
  27904. radius: number;
  27905. cap: number;
  27906. tessellation: number;
  27907. }
  27908. /**
  27909. * @hidden
  27910. **/
  27911. class _InstanceDataStorage {
  27912. visibleInstances: any;
  27913. batchCache: _InstancesBatch;
  27914. instancesBufferSize: number;
  27915. instancesBuffer: Nullable<Buffer>;
  27916. instancesData: Float32Array;
  27917. overridenInstanceCount: number;
  27918. isFrozen: boolean;
  27919. previousBatch: Nullable<_InstancesBatch>;
  27920. hardwareInstancedRendering: boolean;
  27921. sideOrientation: number;
  27922. manualUpdate: boolean;
  27923. }
  27924. /**
  27925. * @hidden
  27926. **/
  27927. export class _InstancesBatch {
  27928. mustReturn: boolean;
  27929. visibleInstances: Nullable<InstancedMesh[]>[];
  27930. renderSelf: boolean[];
  27931. hardwareInstancedRendering: boolean[];
  27932. }
  27933. /**
  27934. * @hidden
  27935. **/
  27936. class _ThinInstanceDataStorage {
  27937. instancesCount: number;
  27938. matrixBuffer: Nullable<Buffer>;
  27939. matrixBufferSize: number;
  27940. matrixData: Nullable<Float32Array>;
  27941. boundingVectors: Array<Vector3>;
  27942. worldMatrices: Nullable<Matrix[]>;
  27943. }
  27944. /**
  27945. * Class used to represent renderable models
  27946. */
  27947. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27948. /**
  27949. * Mesh side orientation : usually the external or front surface
  27950. */
  27951. static readonly FRONTSIDE: number;
  27952. /**
  27953. * Mesh side orientation : usually the internal or back surface
  27954. */
  27955. static readonly BACKSIDE: number;
  27956. /**
  27957. * Mesh side orientation : both internal and external or front and back surfaces
  27958. */
  27959. static readonly DOUBLESIDE: number;
  27960. /**
  27961. * Mesh side orientation : by default, `FRONTSIDE`
  27962. */
  27963. static readonly DEFAULTSIDE: number;
  27964. /**
  27965. * Mesh cap setting : no cap
  27966. */
  27967. static readonly NO_CAP: number;
  27968. /**
  27969. * Mesh cap setting : one cap at the beginning of the mesh
  27970. */
  27971. static readonly CAP_START: number;
  27972. /**
  27973. * Mesh cap setting : one cap at the end of the mesh
  27974. */
  27975. static readonly CAP_END: number;
  27976. /**
  27977. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27978. */
  27979. static readonly CAP_ALL: number;
  27980. /**
  27981. * Mesh pattern setting : no flip or rotate
  27982. */
  27983. static readonly NO_FLIP: number;
  27984. /**
  27985. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27986. */
  27987. static readonly FLIP_TILE: number;
  27988. /**
  27989. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27990. */
  27991. static readonly ROTATE_TILE: number;
  27992. /**
  27993. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27994. */
  27995. static readonly FLIP_ROW: number;
  27996. /**
  27997. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27998. */
  27999. static readonly ROTATE_ROW: number;
  28000. /**
  28001. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28002. */
  28003. static readonly FLIP_N_ROTATE_TILE: number;
  28004. /**
  28005. * Mesh pattern setting : rotate pattern and rotate
  28006. */
  28007. static readonly FLIP_N_ROTATE_ROW: number;
  28008. /**
  28009. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28010. */
  28011. static readonly CENTER: number;
  28012. /**
  28013. * Mesh tile positioning : part tiles on left
  28014. */
  28015. static readonly LEFT: number;
  28016. /**
  28017. * Mesh tile positioning : part tiles on right
  28018. */
  28019. static readonly RIGHT: number;
  28020. /**
  28021. * Mesh tile positioning : part tiles on top
  28022. */
  28023. static readonly TOP: number;
  28024. /**
  28025. * Mesh tile positioning : part tiles on bottom
  28026. */
  28027. static readonly BOTTOM: number;
  28028. /**
  28029. * Gets the default side orientation.
  28030. * @param orientation the orientation to value to attempt to get
  28031. * @returns the default orientation
  28032. * @hidden
  28033. */
  28034. static _GetDefaultSideOrientation(orientation?: number): number;
  28035. private _internalMeshDataInfo;
  28036. get computeBonesUsingShaders(): boolean;
  28037. set computeBonesUsingShaders(value: boolean);
  28038. /**
  28039. * An event triggered before rendering the mesh
  28040. */
  28041. get onBeforeRenderObservable(): Observable<Mesh>;
  28042. /**
  28043. * An event triggered before binding the mesh
  28044. */
  28045. get onBeforeBindObservable(): Observable<Mesh>;
  28046. /**
  28047. * An event triggered after rendering the mesh
  28048. */
  28049. get onAfterRenderObservable(): Observable<Mesh>;
  28050. /**
  28051. * An event triggered before drawing the mesh
  28052. */
  28053. get onBeforeDrawObservable(): Observable<Mesh>;
  28054. private _onBeforeDrawObserver;
  28055. /**
  28056. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28057. */
  28058. set onBeforeDraw(callback: () => void);
  28059. get hasInstances(): boolean;
  28060. get hasThinInstances(): boolean;
  28061. /**
  28062. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28063. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28064. */
  28065. delayLoadState: number;
  28066. /**
  28067. * Gets the list of instances created from this mesh
  28068. * it is not supposed to be modified manually.
  28069. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28070. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28071. */
  28072. instances: InstancedMesh[];
  28073. /**
  28074. * Gets the file containing delay loading data for this mesh
  28075. */
  28076. delayLoadingFile: string;
  28077. /** @hidden */
  28078. _binaryInfo: any;
  28079. /**
  28080. * User defined function used to change how LOD level selection is done
  28081. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28082. */
  28083. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28084. /**
  28085. * Gets or sets the morph target manager
  28086. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28087. */
  28088. get morphTargetManager(): Nullable<MorphTargetManager>;
  28089. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28090. /** @hidden */
  28091. _creationDataStorage: Nullable<_CreationDataStorage>;
  28092. /** @hidden */
  28093. _geometry: Nullable<Geometry>;
  28094. /** @hidden */
  28095. _delayInfo: Array<string>;
  28096. /** @hidden */
  28097. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28098. /** @hidden */
  28099. _instanceDataStorage: _InstanceDataStorage;
  28100. /** @hidden */
  28101. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28102. private _effectiveMaterial;
  28103. /** @hidden */
  28104. _shouldGenerateFlatShading: boolean;
  28105. /** @hidden */
  28106. _originalBuilderSideOrientation: number;
  28107. /**
  28108. * Use this property to change the original side orientation defined at construction time
  28109. */
  28110. overrideMaterialSideOrientation: Nullable<number>;
  28111. /**
  28112. * Gets the source mesh (the one used to clone this one from)
  28113. */
  28114. get source(): Nullable<Mesh>;
  28115. /**
  28116. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28117. */
  28118. get isUnIndexed(): boolean;
  28119. set isUnIndexed(value: boolean);
  28120. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28121. get worldMatrixInstancedBuffer(): Float32Array;
  28122. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28123. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28124. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28125. /**
  28126. * @constructor
  28127. * @param name The value used by scene.getMeshByName() to do a lookup.
  28128. * @param scene The scene to add this mesh to.
  28129. * @param parent The parent of this mesh, if it has one
  28130. * @param source An optional Mesh from which geometry is shared, cloned.
  28131. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28132. * When false, achieved by calling a clone(), also passing False.
  28133. * This will make creation of children, recursive.
  28134. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28135. */
  28136. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28137. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28138. doNotInstantiate: boolean;
  28139. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28140. /**
  28141. * Gets the class name
  28142. * @returns the string "Mesh".
  28143. */
  28144. getClassName(): string;
  28145. /** @hidden */
  28146. get _isMesh(): boolean;
  28147. /**
  28148. * Returns a description of this mesh
  28149. * @param fullDetails define if full details about this mesh must be used
  28150. * @returns a descriptive string representing this mesh
  28151. */
  28152. toString(fullDetails?: boolean): string;
  28153. /** @hidden */
  28154. _unBindEffect(): void;
  28155. /**
  28156. * Gets a boolean indicating if this mesh has LOD
  28157. */
  28158. get hasLODLevels(): boolean;
  28159. /**
  28160. * Gets the list of MeshLODLevel associated with the current mesh
  28161. * @returns an array of MeshLODLevel
  28162. */
  28163. getLODLevels(): MeshLODLevel[];
  28164. private _sortLODLevels;
  28165. /**
  28166. * Add a mesh as LOD level triggered at the given distance.
  28167. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28168. * @param distance The distance from the center of the object to show this level
  28169. * @param mesh The mesh to be added as LOD level (can be null)
  28170. * @return This mesh (for chaining)
  28171. */
  28172. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28173. /**
  28174. * Returns the LOD level mesh at the passed distance or null if not found.
  28175. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28176. * @param distance The distance from the center of the object to show this level
  28177. * @returns a Mesh or `null`
  28178. */
  28179. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28180. /**
  28181. * Remove a mesh from the LOD array
  28182. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28183. * @param mesh defines the mesh to be removed
  28184. * @return This mesh (for chaining)
  28185. */
  28186. removeLODLevel(mesh: Mesh): Mesh;
  28187. /**
  28188. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28189. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28190. * @param camera defines the camera to use to compute distance
  28191. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28192. * @return This mesh (for chaining)
  28193. */
  28194. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28195. /**
  28196. * Gets the mesh internal Geometry object
  28197. */
  28198. get geometry(): Nullable<Geometry>;
  28199. /**
  28200. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28201. * @returns the total number of vertices
  28202. */
  28203. getTotalVertices(): number;
  28204. /**
  28205. * Returns the content of an associated vertex buffer
  28206. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28207. * - VertexBuffer.PositionKind
  28208. * - VertexBuffer.UVKind
  28209. * - VertexBuffer.UV2Kind
  28210. * - VertexBuffer.UV3Kind
  28211. * - VertexBuffer.UV4Kind
  28212. * - VertexBuffer.UV5Kind
  28213. * - VertexBuffer.UV6Kind
  28214. * - VertexBuffer.ColorKind
  28215. * - VertexBuffer.MatricesIndicesKind
  28216. * - VertexBuffer.MatricesIndicesExtraKind
  28217. * - VertexBuffer.MatricesWeightsKind
  28218. * - VertexBuffer.MatricesWeightsExtraKind
  28219. * @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
  28220. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28221. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28222. */
  28223. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28224. /**
  28225. * Returns the mesh VertexBuffer object from the requested `kind`
  28226. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28227. * - VertexBuffer.PositionKind
  28228. * - VertexBuffer.NormalKind
  28229. * - VertexBuffer.UVKind
  28230. * - VertexBuffer.UV2Kind
  28231. * - VertexBuffer.UV3Kind
  28232. * - VertexBuffer.UV4Kind
  28233. * - VertexBuffer.UV5Kind
  28234. * - VertexBuffer.UV6Kind
  28235. * - VertexBuffer.ColorKind
  28236. * - VertexBuffer.MatricesIndicesKind
  28237. * - VertexBuffer.MatricesIndicesExtraKind
  28238. * - VertexBuffer.MatricesWeightsKind
  28239. * - VertexBuffer.MatricesWeightsExtraKind
  28240. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28241. */
  28242. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28243. /**
  28244. * Tests if a specific vertex buffer is associated with this mesh
  28245. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28246. * - VertexBuffer.PositionKind
  28247. * - VertexBuffer.NormalKind
  28248. * - VertexBuffer.UVKind
  28249. * - VertexBuffer.UV2Kind
  28250. * - VertexBuffer.UV3Kind
  28251. * - VertexBuffer.UV4Kind
  28252. * - VertexBuffer.UV5Kind
  28253. * - VertexBuffer.UV6Kind
  28254. * - VertexBuffer.ColorKind
  28255. * - VertexBuffer.MatricesIndicesKind
  28256. * - VertexBuffer.MatricesIndicesExtraKind
  28257. * - VertexBuffer.MatricesWeightsKind
  28258. * - VertexBuffer.MatricesWeightsExtraKind
  28259. * @returns a boolean
  28260. */
  28261. isVerticesDataPresent(kind: string): boolean;
  28262. /**
  28263. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28265. * - VertexBuffer.PositionKind
  28266. * - VertexBuffer.UVKind
  28267. * - VertexBuffer.UV2Kind
  28268. * - VertexBuffer.UV3Kind
  28269. * - VertexBuffer.UV4Kind
  28270. * - VertexBuffer.UV5Kind
  28271. * - VertexBuffer.UV6Kind
  28272. * - VertexBuffer.ColorKind
  28273. * - VertexBuffer.MatricesIndicesKind
  28274. * - VertexBuffer.MatricesIndicesExtraKind
  28275. * - VertexBuffer.MatricesWeightsKind
  28276. * - VertexBuffer.MatricesWeightsExtraKind
  28277. * @returns a boolean
  28278. */
  28279. isVertexBufferUpdatable(kind: string): boolean;
  28280. /**
  28281. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28282. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28283. * - VertexBuffer.PositionKind
  28284. * - VertexBuffer.NormalKind
  28285. * - VertexBuffer.UVKind
  28286. * - VertexBuffer.UV2Kind
  28287. * - VertexBuffer.UV3Kind
  28288. * - VertexBuffer.UV4Kind
  28289. * - VertexBuffer.UV5Kind
  28290. * - VertexBuffer.UV6Kind
  28291. * - VertexBuffer.ColorKind
  28292. * - VertexBuffer.MatricesIndicesKind
  28293. * - VertexBuffer.MatricesIndicesExtraKind
  28294. * - VertexBuffer.MatricesWeightsKind
  28295. * - VertexBuffer.MatricesWeightsExtraKind
  28296. * @returns an array of strings
  28297. */
  28298. getVerticesDataKinds(): string[];
  28299. /**
  28300. * Returns a positive integer : the total number of indices in this mesh geometry.
  28301. * @returns the numner of indices or zero if the mesh has no geometry.
  28302. */
  28303. getTotalIndices(): number;
  28304. /**
  28305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28306. * @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.
  28307. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28308. * @returns the indices array or an empty array if the mesh has no geometry
  28309. */
  28310. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28311. get isBlocked(): boolean;
  28312. /**
  28313. * Determine if the current mesh is ready to be rendered
  28314. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28315. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28316. * @returns true if all associated assets are ready (material, textures, shaders)
  28317. */
  28318. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28319. /**
  28320. * 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.
  28321. */
  28322. get areNormalsFrozen(): boolean;
  28323. /**
  28324. * 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.
  28325. * @returns the current mesh
  28326. */
  28327. freezeNormals(): Mesh;
  28328. /**
  28329. * 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
  28330. * @returns the current mesh
  28331. */
  28332. unfreezeNormals(): Mesh;
  28333. /**
  28334. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28335. */
  28336. set overridenInstanceCount(count: number);
  28337. /** @hidden */
  28338. _preActivate(): Mesh;
  28339. /** @hidden */
  28340. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28341. /** @hidden */
  28342. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28343. protected _afterComputeWorldMatrix(): void;
  28344. /** @hidden */
  28345. _postActivate(): void;
  28346. /**
  28347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28348. * This means the mesh underlying bounding box and sphere are recomputed.
  28349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28350. * @returns the current mesh
  28351. */
  28352. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28353. /** @hidden */
  28354. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28355. /**
  28356. * This function will subdivide the mesh into multiple submeshes
  28357. * @param count defines the expected number of submeshes
  28358. */
  28359. subdivide(count: number): void;
  28360. /**
  28361. * Copy a FloatArray into a specific associated vertex buffer
  28362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28363. * - VertexBuffer.PositionKind
  28364. * - VertexBuffer.UVKind
  28365. * - VertexBuffer.UV2Kind
  28366. * - VertexBuffer.UV3Kind
  28367. * - VertexBuffer.UV4Kind
  28368. * - VertexBuffer.UV5Kind
  28369. * - VertexBuffer.UV6Kind
  28370. * - VertexBuffer.ColorKind
  28371. * - VertexBuffer.MatricesIndicesKind
  28372. * - VertexBuffer.MatricesIndicesExtraKind
  28373. * - VertexBuffer.MatricesWeightsKind
  28374. * - VertexBuffer.MatricesWeightsExtraKind
  28375. * @param data defines the data source
  28376. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28377. * @param stride defines the data stride size (can be null)
  28378. * @returns the current mesh
  28379. */
  28380. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28381. /**
  28382. * Delete a vertex buffer associated with this mesh
  28383. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28384. * - VertexBuffer.PositionKind
  28385. * - VertexBuffer.UVKind
  28386. * - VertexBuffer.UV2Kind
  28387. * - VertexBuffer.UV3Kind
  28388. * - VertexBuffer.UV4Kind
  28389. * - VertexBuffer.UV5Kind
  28390. * - VertexBuffer.UV6Kind
  28391. * - VertexBuffer.ColorKind
  28392. * - VertexBuffer.MatricesIndicesKind
  28393. * - VertexBuffer.MatricesIndicesExtraKind
  28394. * - VertexBuffer.MatricesWeightsKind
  28395. * - VertexBuffer.MatricesWeightsExtraKind
  28396. */
  28397. removeVerticesData(kind: string): void;
  28398. /**
  28399. * Flags an associated vertex buffer as updatable
  28400. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28401. * - VertexBuffer.PositionKind
  28402. * - VertexBuffer.UVKind
  28403. * - VertexBuffer.UV2Kind
  28404. * - VertexBuffer.UV3Kind
  28405. * - VertexBuffer.UV4Kind
  28406. * - VertexBuffer.UV5Kind
  28407. * - VertexBuffer.UV6Kind
  28408. * - VertexBuffer.ColorKind
  28409. * - VertexBuffer.MatricesIndicesKind
  28410. * - VertexBuffer.MatricesIndicesExtraKind
  28411. * - VertexBuffer.MatricesWeightsKind
  28412. * - VertexBuffer.MatricesWeightsExtraKind
  28413. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28414. */
  28415. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28416. /**
  28417. * Sets the mesh global Vertex Buffer
  28418. * @param buffer defines the buffer to use
  28419. * @returns the current mesh
  28420. */
  28421. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28422. /**
  28423. * Update a specific associated vertex buffer
  28424. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28425. * - VertexBuffer.PositionKind
  28426. * - VertexBuffer.UVKind
  28427. * - VertexBuffer.UV2Kind
  28428. * - VertexBuffer.UV3Kind
  28429. * - VertexBuffer.UV4Kind
  28430. * - VertexBuffer.UV5Kind
  28431. * - VertexBuffer.UV6Kind
  28432. * - VertexBuffer.ColorKind
  28433. * - VertexBuffer.MatricesIndicesKind
  28434. * - VertexBuffer.MatricesIndicesExtraKind
  28435. * - VertexBuffer.MatricesWeightsKind
  28436. * - VertexBuffer.MatricesWeightsExtraKind
  28437. * @param data defines the data source
  28438. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28439. * @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)
  28440. * @returns the current mesh
  28441. */
  28442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28443. /**
  28444. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28445. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28446. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28447. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28448. * @returns the current mesh
  28449. */
  28450. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28451. /**
  28452. * Creates a un-shared specific occurence of the geometry for the mesh.
  28453. * @returns the current mesh
  28454. */
  28455. makeGeometryUnique(): Mesh;
  28456. /**
  28457. * Set the index buffer of this mesh
  28458. * @param indices defines the source data
  28459. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28460. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28461. * @returns the current mesh
  28462. */
  28463. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28464. /**
  28465. * Update the current index buffer
  28466. * @param indices defines the source data
  28467. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28468. * @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)
  28469. * @returns the current mesh
  28470. */
  28471. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28472. /**
  28473. * Invert the geometry to move from a right handed system to a left handed one.
  28474. * @returns the current mesh
  28475. */
  28476. toLeftHanded(): Mesh;
  28477. /** @hidden */
  28478. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28479. /** @hidden */
  28480. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28481. /**
  28482. * Registers for this mesh a javascript function called just before the rendering process
  28483. * @param func defines the function to call before rendering this mesh
  28484. * @returns the current mesh
  28485. */
  28486. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28487. /**
  28488. * Disposes a previously registered javascript function called before the rendering
  28489. * @param func defines the function to remove
  28490. * @returns the current mesh
  28491. */
  28492. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28493. /**
  28494. * Registers for this mesh a javascript function called just after the rendering is complete
  28495. * @param func defines the function to call after rendering this mesh
  28496. * @returns the current mesh
  28497. */
  28498. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28499. /**
  28500. * Disposes a previously registered javascript function called after the rendering.
  28501. * @param func defines the function to remove
  28502. * @returns the current mesh
  28503. */
  28504. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28505. /** @hidden */
  28506. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28507. /** @hidden */
  28508. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28509. /** @hidden */
  28510. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28511. /** @hidden */
  28512. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28513. /** @hidden */
  28514. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28515. /** @hidden */
  28516. _rebuild(): void;
  28517. /** @hidden */
  28518. _freeze(): void;
  28519. /** @hidden */
  28520. _unFreeze(): void;
  28521. /**
  28522. * 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
  28523. * @param subMesh defines the subMesh to render
  28524. * @param enableAlphaMode defines if alpha mode can be changed
  28525. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28526. * @returns the current mesh
  28527. */
  28528. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28529. private _onBeforeDraw;
  28530. /**
  28531. * Renormalize the mesh and patch it up if there are no weights
  28532. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28533. * However in the case of zero weights then we set just a single influence to 1.
  28534. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28535. */
  28536. cleanMatrixWeights(): void;
  28537. private normalizeSkinFourWeights;
  28538. private normalizeSkinWeightsAndExtra;
  28539. /**
  28540. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28541. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28542. * the user know there was an issue with importing the mesh
  28543. * @returns a validation object with skinned, valid and report string
  28544. */
  28545. validateSkinning(): {
  28546. skinned: boolean;
  28547. valid: boolean;
  28548. report: string;
  28549. };
  28550. /** @hidden */
  28551. _checkDelayState(): Mesh;
  28552. private _queueLoad;
  28553. /**
  28554. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28555. * A mesh is in the frustum if its bounding box intersects the frustum
  28556. * @param frustumPlanes defines the frustum to test
  28557. * @returns true if the mesh is in the frustum planes
  28558. */
  28559. isInFrustum(frustumPlanes: Plane[]): boolean;
  28560. /**
  28561. * Sets the mesh material by the material or multiMaterial `id` property
  28562. * @param id is a string identifying the material or the multiMaterial
  28563. * @returns the current mesh
  28564. */
  28565. setMaterialByID(id: string): Mesh;
  28566. /**
  28567. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28568. * @returns an array of IAnimatable
  28569. */
  28570. getAnimatables(): IAnimatable[];
  28571. /**
  28572. * Modifies the mesh geometry according to the passed transformation matrix.
  28573. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28574. * The mesh normals are modified using the same transformation.
  28575. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28576. * @param transform defines the transform matrix to use
  28577. * @see https://doc.babylonjs.com/resources/baking_transformations
  28578. * @returns the current mesh
  28579. */
  28580. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28581. /**
  28582. * Modifies the mesh geometry according to its own current World Matrix.
  28583. * The mesh World Matrix is then reset.
  28584. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28585. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28586. * @see https://doc.babylonjs.com/resources/baking_transformations
  28587. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28588. * @returns the current mesh
  28589. */
  28590. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28591. /** @hidden */
  28592. get _positions(): Nullable<Vector3[]>;
  28593. /** @hidden */
  28594. _resetPointsArrayCache(): Mesh;
  28595. /** @hidden */
  28596. _generatePointsArray(): boolean;
  28597. /**
  28598. * Returns a new Mesh object generated from the current mesh properties.
  28599. * This method must not get confused with createInstance()
  28600. * @param name is a string, the name given to the new mesh
  28601. * @param newParent can be any Node object (default `null`)
  28602. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28603. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28604. * @returns a new mesh
  28605. */
  28606. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28607. /**
  28608. * Releases resources associated with this mesh.
  28609. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28610. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28611. */
  28612. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28613. /** @hidden */
  28614. _disposeInstanceSpecificData(): void;
  28615. /** @hidden */
  28616. _disposeThinInstanceSpecificData(): void;
  28617. /**
  28618. * Modifies the mesh geometry according to a displacement map.
  28619. * 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.
  28620. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28621. * @param url is a string, the URL from the image file is to be downloaded.
  28622. * @param minHeight is the lower limit of the displacement.
  28623. * @param maxHeight is the upper limit of the displacement.
  28624. * @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.
  28625. * @param uvOffset is an optional vector2 used to offset UV.
  28626. * @param uvScale is an optional vector2 used to scale UV.
  28627. * @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.
  28628. * @returns the Mesh.
  28629. */
  28630. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28631. /**
  28632. * Modifies the mesh geometry according to a displacementMap buffer.
  28633. * 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.
  28634. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28635. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28636. * @param heightMapWidth is the width of the buffer image.
  28637. * @param heightMapHeight is the height of the buffer image.
  28638. * @param minHeight is the lower limit of the displacement.
  28639. * @param maxHeight is the upper limit of the displacement.
  28640. * @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.
  28641. * @param uvOffset is an optional vector2 used to offset UV.
  28642. * @param uvScale is an optional vector2 used to scale UV.
  28643. * @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.
  28644. * @returns the Mesh.
  28645. */
  28646. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28647. /**
  28648. * Modify the mesh to get a flat shading rendering.
  28649. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28650. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28651. * @returns current mesh
  28652. */
  28653. convertToFlatShadedMesh(): Mesh;
  28654. /**
  28655. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28656. * In other words, more vertices, no more indices and a single bigger VBO.
  28657. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28658. * @returns current mesh
  28659. */
  28660. convertToUnIndexedMesh(): Mesh;
  28661. /**
  28662. * Inverses facet orientations.
  28663. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28664. * @param flipNormals will also inverts the normals
  28665. * @returns current mesh
  28666. */
  28667. flipFaces(flipNormals?: boolean): Mesh;
  28668. /**
  28669. * Increase the number of facets and hence vertices in a mesh
  28670. * Vertex normals are interpolated from existing vertex normals
  28671. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28672. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28673. */
  28674. increaseVertices(numberPerEdge: number): void;
  28675. /**
  28676. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28677. * This will undo any application of covertToFlatShadedMesh
  28678. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28679. */
  28680. forceSharedVertices(): void;
  28681. /** @hidden */
  28682. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28683. /** @hidden */
  28684. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28685. /**
  28686. * Creates a new InstancedMesh object from the mesh model.
  28687. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28688. * @param name defines the name of the new instance
  28689. * @returns a new InstancedMesh
  28690. */
  28691. createInstance(name: string): InstancedMesh;
  28692. /**
  28693. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28694. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28695. * @returns the current mesh
  28696. */
  28697. synchronizeInstances(): Mesh;
  28698. /**
  28699. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28700. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28701. * This should be used together with the simplification to avoid disappearing triangles.
  28702. * @param successCallback an optional success callback to be called after the optimization finished.
  28703. * @returns the current mesh
  28704. */
  28705. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28706. /**
  28707. * Serialize current mesh
  28708. * @param serializationObject defines the object which will receive the serialization data
  28709. */
  28710. serialize(serializationObject: any): void;
  28711. /** @hidden */
  28712. _syncGeometryWithMorphTargetManager(): void;
  28713. /** @hidden */
  28714. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28715. /**
  28716. * Returns a new Mesh object parsed from the source provided.
  28717. * @param parsedMesh is the source
  28718. * @param scene defines the hosting scene
  28719. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28720. * @returns a new Mesh
  28721. */
  28722. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28723. /**
  28724. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28726. * @param name defines the name of the mesh to create
  28727. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28728. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28729. * @param closePath creates a seam between the first and the last points of each path of the path array
  28730. * @param offset is taken in account only if the `pathArray` is containing a single path
  28731. * @param scene defines the hosting scene
  28732. * @param updatable defines if the mesh must be flagged as updatable
  28733. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28734. * @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)
  28735. * @returns a new Mesh
  28736. */
  28737. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28738. /**
  28739. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28740. * @param name defines the name of the mesh to create
  28741. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28742. * @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
  28743. * @param scene defines the hosting scene
  28744. * @param updatable defines if the mesh must be flagged as updatable
  28745. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28746. * @returns a new Mesh
  28747. */
  28748. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28749. /**
  28750. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28751. * @param name defines the name of the mesh to create
  28752. * @param size sets the size (float) of each box side (default 1)
  28753. * @param scene defines the hosting scene
  28754. * @param updatable defines if the mesh must be flagged as updatable
  28755. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28756. * @returns a new Mesh
  28757. */
  28758. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28759. /**
  28760. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28761. * @param name defines the name of the mesh to create
  28762. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28763. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28764. * @param scene defines the hosting scene
  28765. * @param updatable defines if the mesh must be flagged as updatable
  28766. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28767. * @returns a new Mesh
  28768. */
  28769. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28770. /**
  28771. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28772. * @param name defines the name of the mesh to create
  28773. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28774. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28775. * @param scene defines the hosting scene
  28776. * @returns a new Mesh
  28777. */
  28778. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28779. /**
  28780. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28781. * @param name defines the name of the mesh to create
  28782. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28783. * @param diameterTop set the top cap diameter (floats, default 1)
  28784. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28785. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28786. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28787. * @param scene defines the hosting scene
  28788. * @param updatable defines if the mesh must be flagged as updatable
  28789. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28790. * @returns a new Mesh
  28791. */
  28792. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28793. /**
  28794. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28795. * @param name defines the name of the mesh to create
  28796. * @param diameter sets the diameter size (float) of the torus (default 1)
  28797. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28798. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28799. * @param scene defines the hosting scene
  28800. * @param updatable defines if the mesh must be flagged as updatable
  28801. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28802. * @returns a new Mesh
  28803. */
  28804. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28805. /**
  28806. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28807. * @param name defines the name of the mesh to create
  28808. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28809. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28810. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28811. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28812. * @param p the number of windings on X axis (positive integers, default 2)
  28813. * @param q the number of windings on Y axis (positive integers, default 3)
  28814. * @param scene defines the hosting scene
  28815. * @param updatable defines if the mesh must be flagged as updatable
  28816. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28817. * @returns a new Mesh
  28818. */
  28819. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28820. /**
  28821. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28822. * @param name defines the name of the mesh to create
  28823. * @param points is an array successive Vector3
  28824. * @param scene defines the hosting scene
  28825. * @param updatable defines if the mesh must be flagged as updatable
  28826. * @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).
  28827. * @returns a new Mesh
  28828. */
  28829. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28830. /**
  28831. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28832. * @param name defines the name of the mesh to create
  28833. * @param points is an array successive Vector3
  28834. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28835. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28836. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28837. * @param scene defines the hosting scene
  28838. * @param updatable defines if the mesh must be flagged as updatable
  28839. * @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)
  28840. * @returns a new Mesh
  28841. */
  28842. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28843. /**
  28844. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28845. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28846. * 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.
  28847. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28848. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28849. * Remember you can only change the shape positions, not their number when updating a polygon.
  28850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28851. * @param name defines the name of the mesh to create
  28852. * @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
  28853. * @param scene defines the hosting scene
  28854. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28855. * @param updatable defines if the mesh must be flagged as updatable
  28856. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28857. * @param earcutInjection can be used to inject your own earcut reference
  28858. * @returns a new Mesh
  28859. */
  28860. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28861. /**
  28862. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28864. * @param name defines the name of the mesh to create
  28865. * @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
  28866. * @param depth defines the height of extrusion
  28867. * @param scene defines the hosting scene
  28868. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28869. * @param updatable defines if the mesh must be flagged as updatable
  28870. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28871. * @param earcutInjection can be used to inject your own earcut reference
  28872. * @returns a new Mesh
  28873. */
  28874. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28875. /**
  28876. * Creates an extruded shape mesh.
  28877. * 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
  28878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28880. * @param name defines the name of the mesh to create
  28881. * @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
  28882. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28883. * @param scale is the value to scale the shape
  28884. * @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
  28885. * @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
  28886. * @param scene defines the hosting scene
  28887. * @param updatable defines if the mesh must be flagged as updatable
  28888. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28889. * @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)
  28890. * @returns a new Mesh
  28891. */
  28892. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28893. /**
  28894. * Creates an custom extruded shape mesh.
  28895. * The custom extrusion is a parametric shape.
  28896. * It has no predefined shape. Its final shape will depend on the input parameters.
  28897. * Please consider using the same method from the MeshBuilder class instead
  28898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28899. * @param name defines the name of the mesh to create
  28900. * @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
  28901. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28902. * @param scaleFunction is a custom Javascript function called on each path point
  28903. * @param rotationFunction is a custom Javascript function called on each path point
  28904. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28905. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28906. * @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
  28907. * @param scene defines the hosting scene
  28908. * @param updatable defines if the mesh must be flagged as updatable
  28909. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28910. * @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)
  28911. * @returns a new Mesh
  28912. */
  28913. 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;
  28914. /**
  28915. * Creates lathe mesh.
  28916. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28917. * Please consider using the same method from the MeshBuilder class instead
  28918. * @param name defines the name of the mesh to create
  28919. * @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
  28920. * @param radius is the radius value of the lathe
  28921. * @param tessellation is the side number of the lathe.
  28922. * @param scene defines the hosting scene
  28923. * @param updatable defines if the mesh must be flagged as updatable
  28924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28925. * @returns a new Mesh
  28926. */
  28927. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28928. /**
  28929. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28930. * @param name defines the name of the mesh to create
  28931. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28932. * @param scene defines the hosting scene
  28933. * @param updatable defines if the mesh must be flagged as updatable
  28934. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28935. * @returns a new Mesh
  28936. */
  28937. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28938. /**
  28939. * Creates a ground mesh.
  28940. * Please consider using the same method from the MeshBuilder class instead
  28941. * @param name defines the name of the mesh to create
  28942. * @param width set the width of the ground
  28943. * @param height set the height of the ground
  28944. * @param subdivisions sets the number of subdivisions per side
  28945. * @param scene defines the hosting scene
  28946. * @param updatable defines if the mesh must be flagged as updatable
  28947. * @returns a new Mesh
  28948. */
  28949. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28950. /**
  28951. * Creates a tiled ground mesh.
  28952. * Please consider using the same method from the MeshBuilder class instead
  28953. * @param name defines the name of the mesh to create
  28954. * @param xmin set the ground minimum X coordinate
  28955. * @param zmin set the ground minimum Y coordinate
  28956. * @param xmax set the ground maximum X coordinate
  28957. * @param zmax set the ground maximum Z coordinate
  28958. * @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
  28959. * @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
  28960. * @param scene defines the hosting scene
  28961. * @param updatable defines if the mesh must be flagged as updatable
  28962. * @returns a new Mesh
  28963. */
  28964. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28965. w: number;
  28966. h: number;
  28967. }, precision: {
  28968. w: number;
  28969. h: number;
  28970. }, scene: Scene, updatable?: boolean): Mesh;
  28971. /**
  28972. * Creates a ground mesh from a height map.
  28973. * Please consider using the same method from the MeshBuilder class instead
  28974. * @see https://doc.babylonjs.com/babylon101/height_map
  28975. * @param name defines the name of the mesh to create
  28976. * @param url sets the URL of the height map image resource
  28977. * @param width set the ground width size
  28978. * @param height set the ground height size
  28979. * @param subdivisions sets the number of subdivision per side
  28980. * @param minHeight is the minimum altitude on the ground
  28981. * @param maxHeight is the maximum altitude on the ground
  28982. * @param scene defines the hosting scene
  28983. * @param updatable defines if the mesh must be flagged as updatable
  28984. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28985. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28986. * @returns a new Mesh
  28987. */
  28988. 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;
  28989. /**
  28990. * Creates a tube mesh.
  28991. * The tube is a parametric shape.
  28992. * It has no predefined shape. Its final shape will depend on the input parameters.
  28993. * Please consider using the same method from the MeshBuilder class instead
  28994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28995. * @param name defines the name of the mesh to create
  28996. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28997. * @param radius sets the tube radius size
  28998. * @param tessellation is the number of sides on the tubular surface
  28999. * @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
  29000. * @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
  29001. * @param scene defines the hosting scene
  29002. * @param updatable defines if the mesh must be flagged as updatable
  29003. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29004. * @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)
  29005. * @returns a new Mesh
  29006. */
  29007. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29008. (i: number, distance: number): number;
  29009. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29010. /**
  29011. * Creates a polyhedron mesh.
  29012. * Please consider using the same method from the MeshBuilder class instead.
  29013. * * 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
  29014. * * The parameter `size` (positive float, default 1) sets the polygon size
  29015. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29016. * * 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`
  29017. * * 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
  29018. * * 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)`)
  29019. * * 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
  29020. * * 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
  29021. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29022. * * 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
  29023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29024. * @param name defines the name of the mesh to create
  29025. * @param options defines the options used to create the mesh
  29026. * @param scene defines the hosting scene
  29027. * @returns a new Mesh
  29028. */
  29029. static CreatePolyhedron(name: string, options: {
  29030. type?: number;
  29031. size?: number;
  29032. sizeX?: number;
  29033. sizeY?: number;
  29034. sizeZ?: number;
  29035. custom?: any;
  29036. faceUV?: Vector4[];
  29037. faceColors?: Color4[];
  29038. updatable?: boolean;
  29039. sideOrientation?: number;
  29040. }, scene: Scene): Mesh;
  29041. /**
  29042. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29043. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29044. * * 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`)
  29045. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29046. * * 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
  29047. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29048. * * 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
  29049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29050. * @param name defines the name of the mesh
  29051. * @param options defines the options used to create the mesh
  29052. * @param scene defines the hosting scene
  29053. * @returns a new Mesh
  29054. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29055. */
  29056. static CreateIcoSphere(name: string, options: {
  29057. radius?: number;
  29058. flat?: boolean;
  29059. subdivisions?: number;
  29060. sideOrientation?: number;
  29061. updatable?: boolean;
  29062. }, scene: Scene): Mesh;
  29063. /**
  29064. * Creates a decal mesh.
  29065. * Please consider using the same method from the MeshBuilder class instead.
  29066. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29067. * @param name defines the name of the mesh
  29068. * @param sourceMesh defines the mesh receiving the decal
  29069. * @param position sets the position of the decal in world coordinates
  29070. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29071. * @param size sets the decal scaling
  29072. * @param angle sets the angle to rotate the decal
  29073. * @returns a new Mesh
  29074. */
  29075. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29076. /**
  29077. * Prepare internal position array for software CPU skinning
  29078. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29079. */
  29080. setPositionsForCPUSkinning(): Float32Array;
  29081. /**
  29082. * Prepare internal normal array for software CPU skinning
  29083. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29084. */
  29085. setNormalsForCPUSkinning(): Float32Array;
  29086. /**
  29087. * Updates the vertex buffer by applying transformation from the bones
  29088. * @param skeleton defines the skeleton to apply to current mesh
  29089. * @returns the current mesh
  29090. */
  29091. applySkeleton(skeleton: Skeleton): Mesh;
  29092. /**
  29093. * 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
  29094. * @param meshes defines the list of meshes to scan
  29095. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29096. */
  29097. static MinMax(meshes: AbstractMesh[]): {
  29098. min: Vector3;
  29099. max: Vector3;
  29100. };
  29101. /**
  29102. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29103. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29104. * @returns a vector3
  29105. */
  29106. static Center(meshesOrMinMaxVector: {
  29107. min: Vector3;
  29108. max: Vector3;
  29109. } | AbstractMesh[]): Vector3;
  29110. /**
  29111. * Merge the array of meshes into a single mesh for performance reasons.
  29112. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29113. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29114. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29115. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29116. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29117. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29118. * @returns a new mesh
  29119. */
  29120. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29121. /** @hidden */
  29122. addInstance(instance: InstancedMesh): void;
  29123. /** @hidden */
  29124. removeInstance(instance: InstancedMesh): void;
  29125. }
  29126. }
  29127. declare module BABYLON {
  29128. /**
  29129. * This is the base class of all the camera used in the application.
  29130. * @see https://doc.babylonjs.com/features/cameras
  29131. */
  29132. export class Camera extends Node {
  29133. /** @hidden */
  29134. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29135. /**
  29136. * This is the default projection mode used by the cameras.
  29137. * It helps recreating a feeling of perspective and better appreciate depth.
  29138. * This is the best way to simulate real life cameras.
  29139. */
  29140. static readonly PERSPECTIVE_CAMERA: number;
  29141. /**
  29142. * This helps creating camera with an orthographic mode.
  29143. * 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.
  29144. */
  29145. static readonly ORTHOGRAPHIC_CAMERA: number;
  29146. /**
  29147. * This is the default FOV mode for perspective cameras.
  29148. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29149. */
  29150. static readonly FOVMODE_VERTICAL_FIXED: number;
  29151. /**
  29152. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29153. */
  29154. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29155. /**
  29156. * This specifies ther is no need for a camera rig.
  29157. * Basically only one eye is rendered corresponding to the camera.
  29158. */
  29159. static readonly RIG_MODE_NONE: number;
  29160. /**
  29161. * Simulates a camera Rig with one blue eye and one red eye.
  29162. * This can be use with 3d blue and red glasses.
  29163. */
  29164. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29165. /**
  29166. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29167. */
  29168. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29169. /**
  29170. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29171. */
  29172. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29173. /**
  29174. * Defines that both eyes of the camera will be rendered over under each other.
  29175. */
  29176. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29177. /**
  29178. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29179. */
  29180. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29181. /**
  29182. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29183. */
  29184. static readonly RIG_MODE_VR: number;
  29185. /**
  29186. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29187. */
  29188. static readonly RIG_MODE_WEBVR: number;
  29189. /**
  29190. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29191. */
  29192. static readonly RIG_MODE_CUSTOM: number;
  29193. /**
  29194. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29195. */
  29196. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29197. /**
  29198. * Define the input manager associated with the camera.
  29199. */
  29200. inputs: CameraInputsManager<Camera>;
  29201. /** @hidden */
  29202. _position: Vector3;
  29203. /**
  29204. * Define the current local position of the camera in the scene
  29205. */
  29206. get position(): Vector3;
  29207. set position(newPosition: Vector3);
  29208. /**
  29209. * The vector the camera should consider as up.
  29210. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29211. */
  29212. upVector: Vector3;
  29213. /**
  29214. * Define the current limit on the left side for an orthographic camera
  29215. * In scene unit
  29216. */
  29217. orthoLeft: Nullable<number>;
  29218. /**
  29219. * Define the current limit on the right side for an orthographic camera
  29220. * In scene unit
  29221. */
  29222. orthoRight: Nullable<number>;
  29223. /**
  29224. * Define the current limit on the bottom side for an orthographic camera
  29225. * In scene unit
  29226. */
  29227. orthoBottom: Nullable<number>;
  29228. /**
  29229. * Define the current limit on the top side for an orthographic camera
  29230. * In scene unit
  29231. */
  29232. orthoTop: Nullable<number>;
  29233. /**
  29234. * Field Of View is set in Radians. (default is 0.8)
  29235. */
  29236. fov: number;
  29237. /**
  29238. * Define the minimum distance the camera can see from.
  29239. * This is important to note that the depth buffer are not infinite and the closer it starts
  29240. * the more your scene might encounter depth fighting issue.
  29241. */
  29242. minZ: number;
  29243. /**
  29244. * Define the maximum distance the camera can see to.
  29245. * This is important to note that the depth buffer are not infinite and the further it end
  29246. * the more your scene might encounter depth fighting issue.
  29247. */
  29248. maxZ: number;
  29249. /**
  29250. * Define the default inertia of the camera.
  29251. * This helps giving a smooth feeling to the camera movement.
  29252. */
  29253. inertia: number;
  29254. /**
  29255. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29256. */
  29257. mode: number;
  29258. /**
  29259. * Define whether the camera is intermediate.
  29260. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29261. */
  29262. isIntermediate: boolean;
  29263. /**
  29264. * Define the viewport of the camera.
  29265. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29266. */
  29267. viewport: Viewport;
  29268. /**
  29269. * Restricts the camera to viewing objects with the same layerMask.
  29270. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29271. */
  29272. layerMask: number;
  29273. /**
  29274. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29275. */
  29276. fovMode: number;
  29277. /**
  29278. * Rig mode of the camera.
  29279. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29280. * This is normally controlled byt the camera themselves as internal use.
  29281. */
  29282. cameraRigMode: number;
  29283. /**
  29284. * Defines the distance between both "eyes" in case of a RIG
  29285. */
  29286. interaxialDistance: number;
  29287. /**
  29288. * Defines if stereoscopic rendering is done side by side or over under.
  29289. */
  29290. isStereoscopicSideBySide: boolean;
  29291. /**
  29292. * 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
  29293. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29294. * else in the scene. (Eg. security camera)
  29295. *
  29296. * 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)
  29297. */
  29298. customRenderTargets: RenderTargetTexture[];
  29299. /**
  29300. * When set, the camera will render to this render target instead of the default canvas
  29301. *
  29302. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29303. */
  29304. outputRenderTarget: Nullable<RenderTargetTexture>;
  29305. /**
  29306. * Observable triggered when the camera view matrix has changed.
  29307. */
  29308. onViewMatrixChangedObservable: Observable<Camera>;
  29309. /**
  29310. * Observable triggered when the camera Projection matrix has changed.
  29311. */
  29312. onProjectionMatrixChangedObservable: Observable<Camera>;
  29313. /**
  29314. * Observable triggered when the inputs have been processed.
  29315. */
  29316. onAfterCheckInputsObservable: Observable<Camera>;
  29317. /**
  29318. * Observable triggered when reset has been called and applied to the camera.
  29319. */
  29320. onRestoreStateObservable: Observable<Camera>;
  29321. /**
  29322. * Is this camera a part of a rig system?
  29323. */
  29324. isRigCamera: boolean;
  29325. /**
  29326. * If isRigCamera set to true this will be set with the parent camera.
  29327. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29328. */
  29329. rigParent?: Camera;
  29330. /** @hidden */
  29331. _cameraRigParams: any;
  29332. /** @hidden */
  29333. _rigCameras: Camera[];
  29334. /** @hidden */
  29335. _rigPostProcess: Nullable<PostProcess>;
  29336. protected _webvrViewMatrix: Matrix;
  29337. /** @hidden */
  29338. _skipRendering: boolean;
  29339. /** @hidden */
  29340. _projectionMatrix: Matrix;
  29341. /** @hidden */
  29342. _postProcesses: Nullable<PostProcess>[];
  29343. /** @hidden */
  29344. _activeMeshes: SmartArray<AbstractMesh>;
  29345. protected _globalPosition: Vector3;
  29346. /** @hidden */
  29347. _computedViewMatrix: Matrix;
  29348. private _doNotComputeProjectionMatrix;
  29349. private _transformMatrix;
  29350. private _frustumPlanes;
  29351. private _refreshFrustumPlanes;
  29352. private _storedFov;
  29353. private _stateStored;
  29354. /**
  29355. * Instantiates a new camera object.
  29356. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29357. * @see https://doc.babylonjs.com/features/cameras
  29358. * @param name Defines the name of the camera in the scene
  29359. * @param position Defines the position of the camera
  29360. * @param scene Defines the scene the camera belongs too
  29361. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29362. */
  29363. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29364. /**
  29365. * Store current camera state (fov, position, etc..)
  29366. * @returns the camera
  29367. */
  29368. storeState(): Camera;
  29369. /**
  29370. * Restores the camera state values if it has been stored. You must call storeState() first
  29371. */
  29372. protected _restoreStateValues(): boolean;
  29373. /**
  29374. * Restored camera state. You must call storeState() first.
  29375. * @returns true if restored and false otherwise
  29376. */
  29377. restoreState(): boolean;
  29378. /**
  29379. * Gets the class name of the camera.
  29380. * @returns the class name
  29381. */
  29382. getClassName(): string;
  29383. /** @hidden */
  29384. readonly _isCamera: boolean;
  29385. /**
  29386. * Gets a string representation of the camera useful for debug purpose.
  29387. * @param fullDetails Defines that a more verboe level of logging is required
  29388. * @returns the string representation
  29389. */
  29390. toString(fullDetails?: boolean): string;
  29391. /**
  29392. * Gets the current world space position of the camera.
  29393. */
  29394. get globalPosition(): Vector3;
  29395. /**
  29396. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29397. * @returns the active meshe list
  29398. */
  29399. getActiveMeshes(): SmartArray<AbstractMesh>;
  29400. /**
  29401. * Check whether a mesh is part of the current active mesh list of the camera
  29402. * @param mesh Defines the mesh to check
  29403. * @returns true if active, false otherwise
  29404. */
  29405. isActiveMesh(mesh: Mesh): boolean;
  29406. /**
  29407. * Is this camera ready to be used/rendered
  29408. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29409. * @return true if the camera is ready
  29410. */
  29411. isReady(completeCheck?: boolean): boolean;
  29412. /** @hidden */
  29413. _initCache(): void;
  29414. /** @hidden */
  29415. _updateCache(ignoreParentClass?: boolean): void;
  29416. /** @hidden */
  29417. _isSynchronized(): boolean;
  29418. /** @hidden */
  29419. _isSynchronizedViewMatrix(): boolean;
  29420. /** @hidden */
  29421. _isSynchronizedProjectionMatrix(): boolean;
  29422. /**
  29423. * Attach the input controls to a specific dom element to get the input from.
  29424. * @param element Defines the element the controls should be listened from
  29425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29426. */
  29427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29428. /**
  29429. * Detach the current controls from the specified dom element.
  29430. * @param element Defines the element to stop listening the inputs from
  29431. */
  29432. detachControl(element: HTMLElement): void;
  29433. /**
  29434. * Update the camera state according to the different inputs gathered during the frame.
  29435. */
  29436. update(): void;
  29437. /** @hidden */
  29438. _checkInputs(): void;
  29439. /** @hidden */
  29440. get rigCameras(): Camera[];
  29441. /**
  29442. * Gets the post process used by the rig cameras
  29443. */
  29444. get rigPostProcess(): Nullable<PostProcess>;
  29445. /**
  29446. * Internal, gets the first post proces.
  29447. * @returns the first post process to be run on this camera.
  29448. */
  29449. _getFirstPostProcess(): Nullable<PostProcess>;
  29450. private _cascadePostProcessesToRigCams;
  29451. /**
  29452. * Attach a post process to the camera.
  29453. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29454. * @param postProcess The post process to attach to the camera
  29455. * @param insertAt The position of the post process in case several of them are in use in the scene
  29456. * @returns the position the post process has been inserted at
  29457. */
  29458. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29459. /**
  29460. * Detach a post process to the camera.
  29461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29462. * @param postProcess The post process to detach from the camera
  29463. */
  29464. detachPostProcess(postProcess: PostProcess): void;
  29465. /**
  29466. * Gets the current world matrix of the camera
  29467. */
  29468. getWorldMatrix(): Matrix;
  29469. /** @hidden */
  29470. _getViewMatrix(): Matrix;
  29471. /**
  29472. * Gets the current view matrix of the camera.
  29473. * @param force forces the camera to recompute the matrix without looking at the cached state
  29474. * @returns the view matrix
  29475. */
  29476. getViewMatrix(force?: boolean): Matrix;
  29477. /**
  29478. * Freeze the projection matrix.
  29479. * It will prevent the cache check of the camera projection compute and can speed up perf
  29480. * if no parameter of the camera are meant to change
  29481. * @param projection Defines manually a projection if necessary
  29482. */
  29483. freezeProjectionMatrix(projection?: Matrix): void;
  29484. /**
  29485. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29486. */
  29487. unfreezeProjectionMatrix(): void;
  29488. /**
  29489. * Gets the current projection matrix of the camera.
  29490. * @param force forces the camera to recompute the matrix without looking at the cached state
  29491. * @returns the projection matrix
  29492. */
  29493. getProjectionMatrix(force?: boolean): Matrix;
  29494. /**
  29495. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29496. * @returns a Matrix
  29497. */
  29498. getTransformationMatrix(): Matrix;
  29499. private _updateFrustumPlanes;
  29500. /**
  29501. * Checks if a cullable object (mesh...) is in the camera frustum
  29502. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29503. * @param target The object to check
  29504. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29505. * @returns true if the object is in frustum otherwise false
  29506. */
  29507. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29508. /**
  29509. * Checks if a cullable object (mesh...) is in the camera frustum
  29510. * Unlike isInFrustum this cheks the full bounding box
  29511. * @param target The object to check
  29512. * @returns true if the object is in frustum otherwise false
  29513. */
  29514. isCompletelyInFrustum(target: ICullable): boolean;
  29515. /**
  29516. * Gets a ray in the forward direction from the camera.
  29517. * @param length Defines the length of the ray to create
  29518. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29519. * @param origin Defines the start point of the ray which defaults to the camera position
  29520. * @returns the forward ray
  29521. */
  29522. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29523. /**
  29524. * Gets a ray in the forward direction from the camera.
  29525. * @param refRay the ray to (re)use when setting the values
  29526. * @param length Defines the length of the ray to create
  29527. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29528. * @param origin Defines the start point of the ray which defaults to the camera position
  29529. * @returns the forward ray
  29530. */
  29531. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29532. /**
  29533. * Releases resources associated with this node.
  29534. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29535. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29536. */
  29537. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29538. /** @hidden */
  29539. _isLeftCamera: boolean;
  29540. /**
  29541. * Gets the left camera of a rig setup in case of Rigged Camera
  29542. */
  29543. get isLeftCamera(): boolean;
  29544. /** @hidden */
  29545. _isRightCamera: boolean;
  29546. /**
  29547. * Gets the right camera of a rig setup in case of Rigged Camera
  29548. */
  29549. get isRightCamera(): boolean;
  29550. /**
  29551. * Gets the left camera of a rig setup in case of Rigged Camera
  29552. */
  29553. get leftCamera(): Nullable<FreeCamera>;
  29554. /**
  29555. * Gets the right camera of a rig setup in case of Rigged Camera
  29556. */
  29557. get rightCamera(): Nullable<FreeCamera>;
  29558. /**
  29559. * Gets the left camera target of a rig setup in case of Rigged Camera
  29560. * @returns the target position
  29561. */
  29562. getLeftTarget(): Nullable<Vector3>;
  29563. /**
  29564. * Gets the right camera target of a rig setup in case of Rigged Camera
  29565. * @returns the target position
  29566. */
  29567. getRightTarget(): Nullable<Vector3>;
  29568. /**
  29569. * @hidden
  29570. */
  29571. setCameraRigMode(mode: number, rigParams: any): void;
  29572. /** @hidden */
  29573. static _setStereoscopicRigMode(camera: Camera): void;
  29574. /** @hidden */
  29575. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29576. /** @hidden */
  29577. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29578. /** @hidden */
  29579. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29580. /** @hidden */
  29581. _getVRProjectionMatrix(): Matrix;
  29582. protected _updateCameraRotationMatrix(): void;
  29583. protected _updateWebVRCameraRotationMatrix(): void;
  29584. /**
  29585. * This function MUST be overwritten by the different WebVR cameras available.
  29586. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29587. * @hidden
  29588. */
  29589. _getWebVRProjectionMatrix(): Matrix;
  29590. /**
  29591. * This function MUST be overwritten by the different WebVR cameras available.
  29592. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29593. * @hidden
  29594. */
  29595. _getWebVRViewMatrix(): Matrix;
  29596. /** @hidden */
  29597. setCameraRigParameter(name: string, value: any): void;
  29598. /**
  29599. * needs to be overridden by children so sub has required properties to be copied
  29600. * @hidden
  29601. */
  29602. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29603. /**
  29604. * May need to be overridden by children
  29605. * @hidden
  29606. */
  29607. _updateRigCameras(): void;
  29608. /** @hidden */
  29609. _setupInputs(): void;
  29610. /**
  29611. * Serialiaze the camera setup to a json represention
  29612. * @returns the JSON representation
  29613. */
  29614. serialize(): any;
  29615. /**
  29616. * Clones the current camera.
  29617. * @param name The cloned camera name
  29618. * @returns the cloned camera
  29619. */
  29620. clone(name: string): Camera;
  29621. /**
  29622. * Gets the direction of the camera relative to a given local axis.
  29623. * @param localAxis Defines the reference axis to provide a relative direction.
  29624. * @return the direction
  29625. */
  29626. getDirection(localAxis: Vector3): Vector3;
  29627. /**
  29628. * Returns the current camera absolute rotation
  29629. */
  29630. get absoluteRotation(): Quaternion;
  29631. /**
  29632. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29633. * @param localAxis Defines the reference axis to provide a relative direction.
  29634. * @param result Defines the vector to store the result in
  29635. */
  29636. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29637. /**
  29638. * Gets a camera constructor for a given camera type
  29639. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29640. * @param name The name of the camera the result will be able to instantiate
  29641. * @param scene The scene the result will construct the camera in
  29642. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29643. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29644. * @returns a factory method to construc the camera
  29645. */
  29646. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29647. /**
  29648. * Compute the world matrix of the camera.
  29649. * @returns the camera world matrix
  29650. */
  29651. computeWorldMatrix(): Matrix;
  29652. /**
  29653. * Parse a JSON and creates the camera from the parsed information
  29654. * @param parsedCamera The JSON to parse
  29655. * @param scene The scene to instantiate the camera in
  29656. * @returns the newly constructed camera
  29657. */
  29658. static Parse(parsedCamera: any, scene: Scene): Camera;
  29659. }
  29660. }
  29661. declare module BABYLON {
  29662. /**
  29663. * Class containing static functions to help procedurally build meshes
  29664. */
  29665. export class DiscBuilder {
  29666. /**
  29667. * Creates a plane polygonal mesh. By default, this is a disc
  29668. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29669. * * 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
  29670. * * 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
  29671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29672. * * 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
  29673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29674. * @param name defines the name of the mesh
  29675. * @param options defines the options used to create the mesh
  29676. * @param scene defines the hosting scene
  29677. * @returns the plane polygonal mesh
  29678. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29679. */
  29680. static CreateDisc(name: string, options: {
  29681. radius?: number;
  29682. tessellation?: number;
  29683. arc?: number;
  29684. updatable?: boolean;
  29685. sideOrientation?: number;
  29686. frontUVs?: Vector4;
  29687. backUVs?: Vector4;
  29688. }, scene?: Nullable<Scene>): Mesh;
  29689. }
  29690. }
  29691. declare module BABYLON {
  29692. /**
  29693. * Options to be used when creating a FresnelParameters.
  29694. */
  29695. export type IFresnelParametersCreationOptions = {
  29696. /**
  29697. * Define the color used on edges (grazing angle)
  29698. */
  29699. leftColor?: Color3;
  29700. /**
  29701. * Define the color used on center
  29702. */
  29703. rightColor?: Color3;
  29704. /**
  29705. * Define bias applied to computed fresnel term
  29706. */
  29707. bias?: number;
  29708. /**
  29709. * Defined the power exponent applied to fresnel term
  29710. */
  29711. power?: number;
  29712. /**
  29713. * Define if the fresnel effect is enable or not.
  29714. */
  29715. isEnabled?: boolean;
  29716. };
  29717. /**
  29718. * Serialized format for FresnelParameters.
  29719. */
  29720. export type IFresnelParametersSerialized = {
  29721. /**
  29722. * Define the color used on edges (grazing angle) [as an array]
  29723. */
  29724. leftColor: number[];
  29725. /**
  29726. * Define the color used on center [as an array]
  29727. */
  29728. rightColor: number[];
  29729. /**
  29730. * Define bias applied to computed fresnel term
  29731. */
  29732. bias: number;
  29733. /**
  29734. * Defined the power exponent applied to fresnel term
  29735. */
  29736. power?: number;
  29737. /**
  29738. * Define if the fresnel effect is enable or not.
  29739. */
  29740. isEnabled: boolean;
  29741. };
  29742. /**
  29743. * This represents all the required information to add a fresnel effect on a material:
  29744. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29745. */
  29746. export class FresnelParameters {
  29747. private _isEnabled;
  29748. /**
  29749. * Define if the fresnel effect is enable or not.
  29750. */
  29751. get isEnabled(): boolean;
  29752. set isEnabled(value: boolean);
  29753. /**
  29754. * Define the color used on edges (grazing angle)
  29755. */
  29756. leftColor: Color3;
  29757. /**
  29758. * Define the color used on center
  29759. */
  29760. rightColor: Color3;
  29761. /**
  29762. * Define bias applied to computed fresnel term
  29763. */
  29764. bias: number;
  29765. /**
  29766. * Defined the power exponent applied to fresnel term
  29767. */
  29768. power: number;
  29769. /**
  29770. * Creates a new FresnelParameters object.
  29771. *
  29772. * @param options provide your own settings to optionally to override defaults
  29773. */
  29774. constructor(options?: IFresnelParametersCreationOptions);
  29775. /**
  29776. * Clones the current fresnel and its valuues
  29777. * @returns a clone fresnel configuration
  29778. */
  29779. clone(): FresnelParameters;
  29780. /**
  29781. * Determines equality between FresnelParameters objects
  29782. * @param otherFresnelParameters defines the second operand
  29783. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29784. */
  29785. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29786. /**
  29787. * Serializes the current fresnel parameters to a JSON representation.
  29788. * @return the JSON serialization
  29789. */
  29790. serialize(): IFresnelParametersSerialized;
  29791. /**
  29792. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29793. * @param parsedFresnelParameters Define the JSON representation
  29794. * @returns the parsed parameters
  29795. */
  29796. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29797. }
  29798. }
  29799. declare module BABYLON {
  29800. /**
  29801. * This groups all the flags used to control the materials channel.
  29802. */
  29803. export class MaterialFlags {
  29804. private static _DiffuseTextureEnabled;
  29805. /**
  29806. * Are diffuse textures enabled in the application.
  29807. */
  29808. static get DiffuseTextureEnabled(): boolean;
  29809. static set DiffuseTextureEnabled(value: boolean);
  29810. private static _DetailTextureEnabled;
  29811. /**
  29812. * Are detail textures enabled in the application.
  29813. */
  29814. static get DetailTextureEnabled(): boolean;
  29815. static set DetailTextureEnabled(value: boolean);
  29816. private static _AmbientTextureEnabled;
  29817. /**
  29818. * Are ambient textures enabled in the application.
  29819. */
  29820. static get AmbientTextureEnabled(): boolean;
  29821. static set AmbientTextureEnabled(value: boolean);
  29822. private static _OpacityTextureEnabled;
  29823. /**
  29824. * Are opacity textures enabled in the application.
  29825. */
  29826. static get OpacityTextureEnabled(): boolean;
  29827. static set OpacityTextureEnabled(value: boolean);
  29828. private static _ReflectionTextureEnabled;
  29829. /**
  29830. * Are reflection textures enabled in the application.
  29831. */
  29832. static get ReflectionTextureEnabled(): boolean;
  29833. static set ReflectionTextureEnabled(value: boolean);
  29834. private static _EmissiveTextureEnabled;
  29835. /**
  29836. * Are emissive textures enabled in the application.
  29837. */
  29838. static get EmissiveTextureEnabled(): boolean;
  29839. static set EmissiveTextureEnabled(value: boolean);
  29840. private static _SpecularTextureEnabled;
  29841. /**
  29842. * Are specular textures enabled in the application.
  29843. */
  29844. static get SpecularTextureEnabled(): boolean;
  29845. static set SpecularTextureEnabled(value: boolean);
  29846. private static _BumpTextureEnabled;
  29847. /**
  29848. * Are bump textures enabled in the application.
  29849. */
  29850. static get BumpTextureEnabled(): boolean;
  29851. static set BumpTextureEnabled(value: boolean);
  29852. private static _LightmapTextureEnabled;
  29853. /**
  29854. * Are lightmap textures enabled in the application.
  29855. */
  29856. static get LightmapTextureEnabled(): boolean;
  29857. static set LightmapTextureEnabled(value: boolean);
  29858. private static _RefractionTextureEnabled;
  29859. /**
  29860. * Are refraction textures enabled in the application.
  29861. */
  29862. static get RefractionTextureEnabled(): boolean;
  29863. static set RefractionTextureEnabled(value: boolean);
  29864. private static _ColorGradingTextureEnabled;
  29865. /**
  29866. * Are color grading textures enabled in the application.
  29867. */
  29868. static get ColorGradingTextureEnabled(): boolean;
  29869. static set ColorGradingTextureEnabled(value: boolean);
  29870. private static _FresnelEnabled;
  29871. /**
  29872. * Are fresnels enabled in the application.
  29873. */
  29874. static get FresnelEnabled(): boolean;
  29875. static set FresnelEnabled(value: boolean);
  29876. private static _ClearCoatTextureEnabled;
  29877. /**
  29878. * Are clear coat textures enabled in the application.
  29879. */
  29880. static get ClearCoatTextureEnabled(): boolean;
  29881. static set ClearCoatTextureEnabled(value: boolean);
  29882. private static _ClearCoatBumpTextureEnabled;
  29883. /**
  29884. * Are clear coat bump textures enabled in the application.
  29885. */
  29886. static get ClearCoatBumpTextureEnabled(): boolean;
  29887. static set ClearCoatBumpTextureEnabled(value: boolean);
  29888. private static _ClearCoatTintTextureEnabled;
  29889. /**
  29890. * Are clear coat tint textures enabled in the application.
  29891. */
  29892. static get ClearCoatTintTextureEnabled(): boolean;
  29893. static set ClearCoatTintTextureEnabled(value: boolean);
  29894. private static _SheenTextureEnabled;
  29895. /**
  29896. * Are sheen textures enabled in the application.
  29897. */
  29898. static get SheenTextureEnabled(): boolean;
  29899. static set SheenTextureEnabled(value: boolean);
  29900. private static _AnisotropicTextureEnabled;
  29901. /**
  29902. * Are anisotropic textures enabled in the application.
  29903. */
  29904. static get AnisotropicTextureEnabled(): boolean;
  29905. static set AnisotropicTextureEnabled(value: boolean);
  29906. private static _ThicknessTextureEnabled;
  29907. /**
  29908. * Are thickness textures enabled in the application.
  29909. */
  29910. static get ThicknessTextureEnabled(): boolean;
  29911. static set ThicknessTextureEnabled(value: boolean);
  29912. }
  29913. }
  29914. declare module BABYLON {
  29915. /** @hidden */
  29916. export var defaultFragmentDeclaration: {
  29917. name: string;
  29918. shader: string;
  29919. };
  29920. }
  29921. declare module BABYLON {
  29922. /** @hidden */
  29923. export var defaultUboDeclaration: {
  29924. name: string;
  29925. shader: string;
  29926. };
  29927. }
  29928. declare module BABYLON {
  29929. /** @hidden */
  29930. export var prePassDeclaration: {
  29931. name: string;
  29932. shader: string;
  29933. };
  29934. }
  29935. declare module BABYLON {
  29936. /** @hidden */
  29937. export var lightFragmentDeclaration: {
  29938. name: string;
  29939. shader: string;
  29940. };
  29941. }
  29942. declare module BABYLON {
  29943. /** @hidden */
  29944. export var lightUboDeclaration: {
  29945. name: string;
  29946. shader: string;
  29947. };
  29948. }
  29949. declare module BABYLON {
  29950. /** @hidden */
  29951. export var lightsFragmentFunctions: {
  29952. name: string;
  29953. shader: string;
  29954. };
  29955. }
  29956. declare module BABYLON {
  29957. /** @hidden */
  29958. export var shadowsFragmentFunctions: {
  29959. name: string;
  29960. shader: string;
  29961. };
  29962. }
  29963. declare module BABYLON {
  29964. /** @hidden */
  29965. export var fresnelFunction: {
  29966. name: string;
  29967. shader: string;
  29968. };
  29969. }
  29970. declare module BABYLON {
  29971. /** @hidden */
  29972. export var bumpFragmentMainFunctions: {
  29973. name: string;
  29974. shader: string;
  29975. };
  29976. }
  29977. declare module BABYLON {
  29978. /** @hidden */
  29979. export var bumpFragmentFunctions: {
  29980. name: string;
  29981. shader: string;
  29982. };
  29983. }
  29984. declare module BABYLON {
  29985. /** @hidden */
  29986. export var logDepthDeclaration: {
  29987. name: string;
  29988. shader: string;
  29989. };
  29990. }
  29991. declare module BABYLON {
  29992. /** @hidden */
  29993. export var bumpFragment: {
  29994. name: string;
  29995. shader: string;
  29996. };
  29997. }
  29998. declare module BABYLON {
  29999. /** @hidden */
  30000. export var depthPrePass: {
  30001. name: string;
  30002. shader: string;
  30003. };
  30004. }
  30005. declare module BABYLON {
  30006. /** @hidden */
  30007. export var lightFragment: {
  30008. name: string;
  30009. shader: string;
  30010. };
  30011. }
  30012. declare module BABYLON {
  30013. /** @hidden */
  30014. export var logDepthFragment: {
  30015. name: string;
  30016. shader: string;
  30017. };
  30018. }
  30019. declare module BABYLON {
  30020. /** @hidden */
  30021. export var defaultPixelShader: {
  30022. name: string;
  30023. shader: string;
  30024. };
  30025. }
  30026. declare module BABYLON {
  30027. /** @hidden */
  30028. export var defaultVertexDeclaration: {
  30029. name: string;
  30030. shader: string;
  30031. };
  30032. }
  30033. declare module BABYLON {
  30034. /** @hidden */
  30035. export var bumpVertexDeclaration: {
  30036. name: string;
  30037. shader: string;
  30038. };
  30039. }
  30040. declare module BABYLON {
  30041. /** @hidden */
  30042. export var bumpVertex: {
  30043. name: string;
  30044. shader: string;
  30045. };
  30046. }
  30047. declare module BABYLON {
  30048. /** @hidden */
  30049. export var fogVertex: {
  30050. name: string;
  30051. shader: string;
  30052. };
  30053. }
  30054. declare module BABYLON {
  30055. /** @hidden */
  30056. export var shadowsVertex: {
  30057. name: string;
  30058. shader: string;
  30059. };
  30060. }
  30061. declare module BABYLON {
  30062. /** @hidden */
  30063. export var pointCloudVertex: {
  30064. name: string;
  30065. shader: string;
  30066. };
  30067. }
  30068. declare module BABYLON {
  30069. /** @hidden */
  30070. export var logDepthVertex: {
  30071. name: string;
  30072. shader: string;
  30073. };
  30074. }
  30075. declare module BABYLON {
  30076. /** @hidden */
  30077. export var defaultVertexShader: {
  30078. name: string;
  30079. shader: string;
  30080. };
  30081. }
  30082. declare module BABYLON {
  30083. /**
  30084. * @hidden
  30085. */
  30086. export interface IMaterialDetailMapDefines {
  30087. DETAIL: boolean;
  30088. DETAILDIRECTUV: number;
  30089. DETAIL_NORMALBLENDMETHOD: number;
  30090. /** @hidden */
  30091. _areTexturesDirty: boolean;
  30092. }
  30093. /**
  30094. * Define the code related to the detail map parameters of a material
  30095. *
  30096. * Inspired from:
  30097. * 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
  30098. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30099. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30100. */
  30101. export class DetailMapConfiguration {
  30102. private _texture;
  30103. /**
  30104. * The detail texture of the material.
  30105. */
  30106. texture: Nullable<BaseTexture>;
  30107. /**
  30108. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30109. * Bigger values mean stronger blending
  30110. */
  30111. diffuseBlendLevel: number;
  30112. /**
  30113. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30114. * Bigger values mean stronger blending. Only used with PBR materials
  30115. */
  30116. roughnessBlendLevel: number;
  30117. /**
  30118. * Defines how strong the bump effect from the detail map is
  30119. * Bigger values mean stronger effect
  30120. */
  30121. bumpLevel: number;
  30122. private _normalBlendMethod;
  30123. /**
  30124. * The method used to blend the bump and detail normals together
  30125. */
  30126. normalBlendMethod: number;
  30127. private _isEnabled;
  30128. /**
  30129. * Enable or disable the detail map on this material
  30130. */
  30131. isEnabled: boolean;
  30132. /** @hidden */
  30133. private _internalMarkAllSubMeshesAsTexturesDirty;
  30134. /** @hidden */
  30135. _markAllSubMeshesAsTexturesDirty(): void;
  30136. /**
  30137. * Instantiate a new detail map
  30138. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30139. */
  30140. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30141. /**
  30142. * Gets whether the submesh is ready to be used or not.
  30143. * @param defines the list of "defines" to update.
  30144. * @param scene defines the scene the material belongs to.
  30145. * @returns - boolean indicating that the submesh is ready or not.
  30146. */
  30147. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30148. /**
  30149. * Update the defines for detail map usage
  30150. * @param defines the list of "defines" to update.
  30151. * @param scene defines the scene the material belongs to.
  30152. */
  30153. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30154. /**
  30155. * Binds the material data.
  30156. * @param uniformBuffer defines the Uniform buffer to fill in.
  30157. * @param scene defines the scene the material belongs to.
  30158. * @param isFrozen defines whether the material is frozen or not.
  30159. */
  30160. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30161. /**
  30162. * Checks to see if a texture is used in the material.
  30163. * @param texture - Base texture to use.
  30164. * @returns - Boolean specifying if a texture is used in the material.
  30165. */
  30166. hasTexture(texture: BaseTexture): boolean;
  30167. /**
  30168. * Returns an array of the actively used textures.
  30169. * @param activeTextures Array of BaseTextures
  30170. */
  30171. getActiveTextures(activeTextures: BaseTexture[]): void;
  30172. /**
  30173. * Returns the animatable textures.
  30174. * @param animatables Array of animatable textures.
  30175. */
  30176. getAnimatables(animatables: IAnimatable[]): void;
  30177. /**
  30178. * Disposes the resources of the material.
  30179. * @param forceDisposeTextures - Forces the disposal of all textures.
  30180. */
  30181. dispose(forceDisposeTextures?: boolean): void;
  30182. /**
  30183. * Get the current class name useful for serialization or dynamic coding.
  30184. * @returns "DetailMap"
  30185. */
  30186. getClassName(): string;
  30187. /**
  30188. * Add the required uniforms to the current list.
  30189. * @param uniforms defines the current uniform list.
  30190. */
  30191. static AddUniforms(uniforms: string[]): void;
  30192. /**
  30193. * Add the required samplers to the current list.
  30194. * @param samplers defines the current sampler list.
  30195. */
  30196. static AddSamplers(samplers: string[]): void;
  30197. /**
  30198. * Add the required uniforms to the current buffer.
  30199. * @param uniformBuffer defines the current uniform buffer.
  30200. */
  30201. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30202. /**
  30203. * Makes a duplicate of the current instance into another one.
  30204. * @param detailMap define the instance where to copy the info
  30205. */
  30206. copyTo(detailMap: DetailMapConfiguration): void;
  30207. /**
  30208. * Serializes this detail map instance
  30209. * @returns - An object with the serialized instance.
  30210. */
  30211. serialize(): any;
  30212. /**
  30213. * Parses a detail map setting from a serialized object.
  30214. * @param source - Serialized object.
  30215. * @param scene Defines the scene we are parsing for
  30216. * @param rootUrl Defines the rootUrl to load from
  30217. */
  30218. parse(source: any, scene: Scene, rootUrl: string): void;
  30219. }
  30220. }
  30221. declare module BABYLON {
  30222. /** @hidden */
  30223. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30224. MAINUV1: boolean;
  30225. MAINUV2: boolean;
  30226. DIFFUSE: boolean;
  30227. DIFFUSEDIRECTUV: number;
  30228. DETAIL: boolean;
  30229. DETAILDIRECTUV: number;
  30230. DETAIL_NORMALBLENDMETHOD: number;
  30231. AMBIENT: boolean;
  30232. AMBIENTDIRECTUV: number;
  30233. OPACITY: boolean;
  30234. OPACITYDIRECTUV: number;
  30235. OPACITYRGB: boolean;
  30236. REFLECTION: boolean;
  30237. EMISSIVE: boolean;
  30238. EMISSIVEDIRECTUV: number;
  30239. SPECULAR: boolean;
  30240. SPECULARDIRECTUV: number;
  30241. BUMP: boolean;
  30242. BUMPDIRECTUV: number;
  30243. PARALLAX: boolean;
  30244. PARALLAXOCCLUSION: boolean;
  30245. SPECULAROVERALPHA: boolean;
  30246. CLIPPLANE: boolean;
  30247. CLIPPLANE2: boolean;
  30248. CLIPPLANE3: boolean;
  30249. CLIPPLANE4: boolean;
  30250. CLIPPLANE5: boolean;
  30251. CLIPPLANE6: boolean;
  30252. ALPHATEST: boolean;
  30253. DEPTHPREPASS: boolean;
  30254. ALPHAFROMDIFFUSE: boolean;
  30255. POINTSIZE: boolean;
  30256. FOG: boolean;
  30257. SPECULARTERM: boolean;
  30258. DIFFUSEFRESNEL: boolean;
  30259. OPACITYFRESNEL: boolean;
  30260. REFLECTIONFRESNEL: boolean;
  30261. REFRACTIONFRESNEL: boolean;
  30262. EMISSIVEFRESNEL: boolean;
  30263. FRESNEL: boolean;
  30264. NORMAL: boolean;
  30265. UV1: boolean;
  30266. UV2: boolean;
  30267. VERTEXCOLOR: boolean;
  30268. VERTEXALPHA: boolean;
  30269. NUM_BONE_INFLUENCERS: number;
  30270. BonesPerMesh: number;
  30271. BONETEXTURE: boolean;
  30272. INSTANCES: boolean;
  30273. THIN_INSTANCES: boolean;
  30274. GLOSSINESS: boolean;
  30275. ROUGHNESS: boolean;
  30276. EMISSIVEASILLUMINATION: boolean;
  30277. LINKEMISSIVEWITHDIFFUSE: boolean;
  30278. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30279. LIGHTMAP: boolean;
  30280. LIGHTMAPDIRECTUV: number;
  30281. OBJECTSPACE_NORMALMAP: boolean;
  30282. USELIGHTMAPASSHADOWMAP: boolean;
  30283. REFLECTIONMAP_3D: boolean;
  30284. REFLECTIONMAP_SPHERICAL: boolean;
  30285. REFLECTIONMAP_PLANAR: boolean;
  30286. REFLECTIONMAP_CUBIC: boolean;
  30287. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30288. REFLECTIONMAP_PROJECTION: boolean;
  30289. REFLECTIONMAP_SKYBOX: boolean;
  30290. REFLECTIONMAP_EXPLICIT: boolean;
  30291. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30292. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30293. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30294. INVERTCUBICMAP: boolean;
  30295. LOGARITHMICDEPTH: boolean;
  30296. REFRACTION: boolean;
  30297. REFRACTIONMAP_3D: boolean;
  30298. REFLECTIONOVERALPHA: boolean;
  30299. TWOSIDEDLIGHTING: boolean;
  30300. SHADOWFLOAT: boolean;
  30301. MORPHTARGETS: boolean;
  30302. MORPHTARGETS_NORMAL: boolean;
  30303. MORPHTARGETS_TANGENT: boolean;
  30304. MORPHTARGETS_UV: boolean;
  30305. NUM_MORPH_INFLUENCERS: number;
  30306. NONUNIFORMSCALING: boolean;
  30307. PREMULTIPLYALPHA: boolean;
  30308. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30309. ALPHABLEND: boolean;
  30310. PREPASS: boolean;
  30311. SCENE_MRT_COUNT: number;
  30312. RGBDLIGHTMAP: boolean;
  30313. RGBDREFLECTION: boolean;
  30314. RGBDREFRACTION: boolean;
  30315. IMAGEPROCESSING: boolean;
  30316. VIGNETTE: boolean;
  30317. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30318. VIGNETTEBLENDMODEOPAQUE: boolean;
  30319. TONEMAPPING: boolean;
  30320. TONEMAPPING_ACES: boolean;
  30321. CONTRAST: boolean;
  30322. COLORCURVES: boolean;
  30323. COLORGRADING: boolean;
  30324. COLORGRADING3D: boolean;
  30325. SAMPLER3DGREENDEPTH: boolean;
  30326. SAMPLER3DBGRMAP: boolean;
  30327. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30328. MULTIVIEW: boolean;
  30329. /**
  30330. * If the reflection texture on this material is in linear color space
  30331. * @hidden
  30332. */
  30333. IS_REFLECTION_LINEAR: boolean;
  30334. /**
  30335. * If the refraction texture on this material is in linear color space
  30336. * @hidden
  30337. */
  30338. IS_REFRACTION_LINEAR: boolean;
  30339. EXPOSURE: boolean;
  30340. constructor();
  30341. setReflectionMode(modeToEnable: string): void;
  30342. }
  30343. /**
  30344. * This is the default material used in Babylon. It is the best trade off between quality
  30345. * and performances.
  30346. * @see https://doc.babylonjs.com/babylon101/materials
  30347. */
  30348. export class StandardMaterial extends PushMaterial {
  30349. private _diffuseTexture;
  30350. /**
  30351. * The basic texture of the material as viewed under a light.
  30352. */
  30353. diffuseTexture: Nullable<BaseTexture>;
  30354. private _ambientTexture;
  30355. /**
  30356. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30357. */
  30358. ambientTexture: Nullable<BaseTexture>;
  30359. private _opacityTexture;
  30360. /**
  30361. * Define the transparency of the material from a texture.
  30362. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30363. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30364. */
  30365. opacityTexture: Nullable<BaseTexture>;
  30366. private _reflectionTexture;
  30367. /**
  30368. * Define the texture used to display the reflection.
  30369. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30370. */
  30371. reflectionTexture: Nullable<BaseTexture>;
  30372. private _emissiveTexture;
  30373. /**
  30374. * Define texture of the material as if self lit.
  30375. * This will be mixed in the final result even in the absence of light.
  30376. */
  30377. emissiveTexture: Nullable<BaseTexture>;
  30378. private _specularTexture;
  30379. /**
  30380. * Define how the color and intensity of the highlight given by the light in the material.
  30381. */
  30382. specularTexture: Nullable<BaseTexture>;
  30383. private _bumpTexture;
  30384. /**
  30385. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30386. * 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.
  30387. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30388. */
  30389. bumpTexture: Nullable<BaseTexture>;
  30390. private _lightmapTexture;
  30391. /**
  30392. * Complex lighting can be computationally expensive to compute at runtime.
  30393. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30394. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30395. */
  30396. lightmapTexture: Nullable<BaseTexture>;
  30397. private _refractionTexture;
  30398. /**
  30399. * Define the texture used to display the refraction.
  30400. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30401. */
  30402. refractionTexture: Nullable<BaseTexture>;
  30403. /**
  30404. * The color of the material lit by the environmental background lighting.
  30405. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30406. */
  30407. ambientColor: Color3;
  30408. /**
  30409. * The basic color of the material as viewed under a light.
  30410. */
  30411. diffuseColor: Color3;
  30412. /**
  30413. * Define how the color and intensity of the highlight given by the light in the material.
  30414. */
  30415. specularColor: Color3;
  30416. /**
  30417. * Define the color of the material as if self lit.
  30418. * This will be mixed in the final result even in the absence of light.
  30419. */
  30420. emissiveColor: Color3;
  30421. /**
  30422. * Defines how sharp are the highlights in the material.
  30423. * The bigger the value the sharper giving a more glossy feeling to the result.
  30424. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30425. */
  30426. specularPower: number;
  30427. private _useAlphaFromDiffuseTexture;
  30428. /**
  30429. * Does the transparency come from the diffuse texture alpha channel.
  30430. */
  30431. useAlphaFromDiffuseTexture: boolean;
  30432. private _useEmissiveAsIllumination;
  30433. /**
  30434. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30435. */
  30436. useEmissiveAsIllumination: boolean;
  30437. private _linkEmissiveWithDiffuse;
  30438. /**
  30439. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30440. * the emissive level when the final color is close to one.
  30441. */
  30442. linkEmissiveWithDiffuse: boolean;
  30443. private _useSpecularOverAlpha;
  30444. /**
  30445. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30446. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30447. */
  30448. useSpecularOverAlpha: boolean;
  30449. private _useReflectionOverAlpha;
  30450. /**
  30451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30453. */
  30454. useReflectionOverAlpha: boolean;
  30455. private _disableLighting;
  30456. /**
  30457. * Does lights from the scene impacts this material.
  30458. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30459. */
  30460. disableLighting: boolean;
  30461. private _useObjectSpaceNormalMap;
  30462. /**
  30463. * Allows using an object space normal map (instead of tangent space).
  30464. */
  30465. useObjectSpaceNormalMap: boolean;
  30466. private _useParallax;
  30467. /**
  30468. * Is parallax enabled or not.
  30469. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30470. */
  30471. useParallax: boolean;
  30472. private _useParallaxOcclusion;
  30473. /**
  30474. * Is parallax occlusion enabled or not.
  30475. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30476. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30477. */
  30478. useParallaxOcclusion: boolean;
  30479. /**
  30480. * 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.
  30481. */
  30482. parallaxScaleBias: number;
  30483. private _roughness;
  30484. /**
  30485. * Helps to define how blurry the reflections should appears in the material.
  30486. */
  30487. roughness: number;
  30488. /**
  30489. * In case of refraction, define the value of the index of refraction.
  30490. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30491. */
  30492. indexOfRefraction: number;
  30493. /**
  30494. * Invert the refraction texture alongside the y axis.
  30495. * It can be useful with procedural textures or probe for instance.
  30496. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30497. */
  30498. invertRefractionY: boolean;
  30499. /**
  30500. * Defines the alpha limits in alpha test mode.
  30501. */
  30502. alphaCutOff: number;
  30503. private _useLightmapAsShadowmap;
  30504. /**
  30505. * In case of light mapping, define whether the map contains light or shadow informations.
  30506. */
  30507. useLightmapAsShadowmap: boolean;
  30508. private _diffuseFresnelParameters;
  30509. /**
  30510. * Define the diffuse fresnel parameters of the material.
  30511. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30512. */
  30513. diffuseFresnelParameters: FresnelParameters;
  30514. private _opacityFresnelParameters;
  30515. /**
  30516. * Define the opacity fresnel parameters of the material.
  30517. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30518. */
  30519. opacityFresnelParameters: FresnelParameters;
  30520. private _reflectionFresnelParameters;
  30521. /**
  30522. * Define the reflection fresnel parameters of the material.
  30523. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30524. */
  30525. reflectionFresnelParameters: FresnelParameters;
  30526. private _refractionFresnelParameters;
  30527. /**
  30528. * Define the refraction fresnel parameters of the material.
  30529. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30530. */
  30531. refractionFresnelParameters: FresnelParameters;
  30532. private _emissiveFresnelParameters;
  30533. /**
  30534. * Define the emissive fresnel parameters of the material.
  30535. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30536. */
  30537. emissiveFresnelParameters: FresnelParameters;
  30538. private _useReflectionFresnelFromSpecular;
  30539. /**
  30540. * If true automatically deducts the fresnels values from the material specularity.
  30541. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30542. */
  30543. useReflectionFresnelFromSpecular: boolean;
  30544. private _useGlossinessFromSpecularMapAlpha;
  30545. /**
  30546. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30547. */
  30548. useGlossinessFromSpecularMapAlpha: boolean;
  30549. private _maxSimultaneousLights;
  30550. /**
  30551. * Defines the maximum number of lights that can be used in the material
  30552. */
  30553. maxSimultaneousLights: number;
  30554. private _invertNormalMapX;
  30555. /**
  30556. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30557. */
  30558. invertNormalMapX: boolean;
  30559. private _invertNormalMapY;
  30560. /**
  30561. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30562. */
  30563. invertNormalMapY: boolean;
  30564. private _twoSidedLighting;
  30565. /**
  30566. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30567. */
  30568. twoSidedLighting: boolean;
  30569. /**
  30570. * Default configuration related to image processing available in the standard Material.
  30571. */
  30572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30573. /**
  30574. * Gets the image processing configuration used either in this material.
  30575. */
  30576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30577. /**
  30578. * Sets the Default image processing configuration used either in the this material.
  30579. *
  30580. * If sets to null, the scene one is in use.
  30581. */
  30582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30583. /**
  30584. * Keep track of the image processing observer to allow dispose and replace.
  30585. */
  30586. private _imageProcessingObserver;
  30587. /**
  30588. * Attaches a new image processing configuration to the Standard Material.
  30589. * @param configuration
  30590. */
  30591. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30592. /**
  30593. * Gets wether the color curves effect is enabled.
  30594. */
  30595. get cameraColorCurvesEnabled(): boolean;
  30596. /**
  30597. * Sets wether the color curves effect is enabled.
  30598. */
  30599. set cameraColorCurvesEnabled(value: boolean);
  30600. /**
  30601. * Gets wether the color grading effect is enabled.
  30602. */
  30603. get cameraColorGradingEnabled(): boolean;
  30604. /**
  30605. * Gets wether the color grading effect is enabled.
  30606. */
  30607. set cameraColorGradingEnabled(value: boolean);
  30608. /**
  30609. * Gets wether tonemapping is enabled or not.
  30610. */
  30611. get cameraToneMappingEnabled(): boolean;
  30612. /**
  30613. * Sets wether tonemapping is enabled or not
  30614. */
  30615. set cameraToneMappingEnabled(value: boolean);
  30616. /**
  30617. * The camera exposure used on this material.
  30618. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30619. * This corresponds to a photographic exposure.
  30620. */
  30621. get cameraExposure(): number;
  30622. /**
  30623. * The camera exposure used on this material.
  30624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30625. * This corresponds to a photographic exposure.
  30626. */
  30627. set cameraExposure(value: number);
  30628. /**
  30629. * Gets The camera contrast used on this material.
  30630. */
  30631. get cameraContrast(): number;
  30632. /**
  30633. * Sets The camera contrast used on this material.
  30634. */
  30635. set cameraContrast(value: number);
  30636. /**
  30637. * Gets the Color Grading 2D Lookup Texture.
  30638. */
  30639. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30640. /**
  30641. * Sets the Color Grading 2D Lookup Texture.
  30642. */
  30643. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30644. /**
  30645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30647. * 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;
  30648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30649. */
  30650. get cameraColorCurves(): Nullable<ColorCurves>;
  30651. /**
  30652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30654. * 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;
  30655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30656. */
  30657. set cameraColorCurves(value: Nullable<ColorCurves>);
  30658. /**
  30659. * Can this material render to several textures at once
  30660. */
  30661. get canRenderToMRT(): boolean;
  30662. /**
  30663. * Defines the detail map parameters for the material.
  30664. */
  30665. readonly detailMap: DetailMapConfiguration;
  30666. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30667. protected _worldViewProjectionMatrix: Matrix;
  30668. protected _globalAmbientColor: Color3;
  30669. protected _useLogarithmicDepth: boolean;
  30670. protected _rebuildInParallel: boolean;
  30671. /**
  30672. * Instantiates a new standard material.
  30673. * This is the default material used in Babylon. It is the best trade off between quality
  30674. * and performances.
  30675. * @see https://doc.babylonjs.com/babylon101/materials
  30676. * @param name Define the name of the material in the scene
  30677. * @param scene Define the scene the material belong to
  30678. */
  30679. constructor(name: string, scene: Scene);
  30680. /**
  30681. * Gets a boolean indicating that current material needs to register RTT
  30682. */
  30683. get hasRenderTargetTextures(): boolean;
  30684. /**
  30685. * Gets the current class name of the material e.g. "StandardMaterial"
  30686. * Mainly use in serialization.
  30687. * @returns the class name
  30688. */
  30689. getClassName(): string;
  30690. /**
  30691. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30692. * You can try switching to logarithmic depth.
  30693. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30694. */
  30695. get useLogarithmicDepth(): boolean;
  30696. set useLogarithmicDepth(value: boolean);
  30697. /**
  30698. * Specifies if the material will require alpha blending
  30699. * @returns a boolean specifying if alpha blending is needed
  30700. */
  30701. needAlphaBlending(): boolean;
  30702. /**
  30703. * Specifies if this material should be rendered in alpha test mode
  30704. * @returns a boolean specifying if an alpha test is needed.
  30705. */
  30706. needAlphaTesting(): boolean;
  30707. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30708. /**
  30709. * Get the texture used for alpha test purpose.
  30710. * @returns the diffuse texture in case of the standard material.
  30711. */
  30712. getAlphaTestTexture(): Nullable<BaseTexture>;
  30713. /**
  30714. * Get if the submesh is ready to be used and all its information available.
  30715. * Child classes can use it to update shaders
  30716. * @param mesh defines the mesh to check
  30717. * @param subMesh defines which submesh to check
  30718. * @param useInstances specifies that instances should be used
  30719. * @returns a boolean indicating that the submesh is ready or not
  30720. */
  30721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30722. /**
  30723. * Builds the material UBO layouts.
  30724. * Used internally during the effect preparation.
  30725. */
  30726. buildUniformLayout(): void;
  30727. /**
  30728. * Unbinds the material from the mesh
  30729. */
  30730. unbind(): void;
  30731. /**
  30732. * Binds the submesh to this material by preparing the effect and shader to draw
  30733. * @param world defines the world transformation matrix
  30734. * @param mesh defines the mesh containing the submesh
  30735. * @param subMesh defines the submesh to bind the material to
  30736. */
  30737. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30738. /**
  30739. * Get the list of animatables in the material.
  30740. * @returns the list of animatables object used in the material
  30741. */
  30742. getAnimatables(): IAnimatable[];
  30743. /**
  30744. * Gets the active textures from the material
  30745. * @returns an array of textures
  30746. */
  30747. getActiveTextures(): BaseTexture[];
  30748. /**
  30749. * Specifies if the material uses a texture
  30750. * @param texture defines the texture to check against the material
  30751. * @returns a boolean specifying if the material uses the texture
  30752. */
  30753. hasTexture(texture: BaseTexture): boolean;
  30754. /**
  30755. * Disposes the material
  30756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30758. */
  30759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30760. /**
  30761. * Makes a duplicate of the material, and gives it a new name
  30762. * @param name defines the new name for the duplicated material
  30763. * @returns the cloned material
  30764. */
  30765. clone(name: string): StandardMaterial;
  30766. /**
  30767. * Serializes this material in a JSON representation
  30768. * @returns the serialized material object
  30769. */
  30770. serialize(): any;
  30771. /**
  30772. * Creates a standard material from parsed material data
  30773. * @param source defines the JSON representation of the material
  30774. * @param scene defines the hosting scene
  30775. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30776. * @returns a new standard material
  30777. */
  30778. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30779. /**
  30780. * Are diffuse textures enabled in the application.
  30781. */
  30782. static get DiffuseTextureEnabled(): boolean;
  30783. static set DiffuseTextureEnabled(value: boolean);
  30784. /**
  30785. * Are detail textures enabled in the application.
  30786. */
  30787. static get DetailTextureEnabled(): boolean;
  30788. static set DetailTextureEnabled(value: boolean);
  30789. /**
  30790. * Are ambient textures enabled in the application.
  30791. */
  30792. static get AmbientTextureEnabled(): boolean;
  30793. static set AmbientTextureEnabled(value: boolean);
  30794. /**
  30795. * Are opacity textures enabled in the application.
  30796. */
  30797. static get OpacityTextureEnabled(): boolean;
  30798. static set OpacityTextureEnabled(value: boolean);
  30799. /**
  30800. * Are reflection textures enabled in the application.
  30801. */
  30802. static get ReflectionTextureEnabled(): boolean;
  30803. static set ReflectionTextureEnabled(value: boolean);
  30804. /**
  30805. * Are emissive textures enabled in the application.
  30806. */
  30807. static get EmissiveTextureEnabled(): boolean;
  30808. static set EmissiveTextureEnabled(value: boolean);
  30809. /**
  30810. * Are specular textures enabled in the application.
  30811. */
  30812. static get SpecularTextureEnabled(): boolean;
  30813. static set SpecularTextureEnabled(value: boolean);
  30814. /**
  30815. * Are bump textures enabled in the application.
  30816. */
  30817. static get BumpTextureEnabled(): boolean;
  30818. static set BumpTextureEnabled(value: boolean);
  30819. /**
  30820. * Are lightmap textures enabled in the application.
  30821. */
  30822. static get LightmapTextureEnabled(): boolean;
  30823. static set LightmapTextureEnabled(value: boolean);
  30824. /**
  30825. * Are refraction textures enabled in the application.
  30826. */
  30827. static get RefractionTextureEnabled(): boolean;
  30828. static set RefractionTextureEnabled(value: boolean);
  30829. /**
  30830. * Are color grading textures enabled in the application.
  30831. */
  30832. static get ColorGradingTextureEnabled(): boolean;
  30833. static set ColorGradingTextureEnabled(value: boolean);
  30834. /**
  30835. * Are fresnels enabled in the application.
  30836. */
  30837. static get FresnelEnabled(): boolean;
  30838. static set FresnelEnabled(value: boolean);
  30839. }
  30840. }
  30841. declare module BABYLON {
  30842. /**
  30843. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30844. *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.
  30845. * The SPS is also a particle system. It provides some methods to manage the particles.
  30846. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30847. *
  30848. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30849. */
  30850. export class SolidParticleSystem implements IDisposable {
  30851. /**
  30852. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30853. * Example : var p = SPS.particles[i];
  30854. */
  30855. particles: SolidParticle[];
  30856. /**
  30857. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30858. */
  30859. nbParticles: number;
  30860. /**
  30861. * If the particles must ever face the camera (default false). Useful for planar particles.
  30862. */
  30863. billboard: boolean;
  30864. /**
  30865. * Recompute normals when adding a shape
  30866. */
  30867. recomputeNormals: boolean;
  30868. /**
  30869. * This a counter ofr your own usage. It's not set by any SPS functions.
  30870. */
  30871. counter: number;
  30872. /**
  30873. * The SPS name. This name is also given to the underlying mesh.
  30874. */
  30875. name: string;
  30876. /**
  30877. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30878. */
  30879. mesh: Mesh;
  30880. /**
  30881. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30882. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30883. */
  30884. vars: any;
  30885. /**
  30886. * This array is populated when the SPS is set as 'pickable'.
  30887. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30888. * Each element of this array is an object `{idx: int, faceId: int}`.
  30889. * `idx` is the picked particle index in the `SPS.particles` array
  30890. * `faceId` is the picked face index counted within this particle.
  30891. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30892. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30893. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30894. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30895. */
  30896. pickedParticles: {
  30897. idx: number;
  30898. faceId: number;
  30899. }[];
  30900. /**
  30901. * This array is populated when the SPS is set as 'pickable'
  30902. * Each key of this array is a submesh index.
  30903. * Each element of this array is a second array defined like this :
  30904. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30905. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30906. * `idx` is the picked particle index in the `SPS.particles` array
  30907. * `faceId` is the picked face index counted within this particle.
  30908. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30909. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30910. */
  30911. pickedBySubMesh: {
  30912. idx: number;
  30913. faceId: number;
  30914. }[][];
  30915. /**
  30916. * This array is populated when `enableDepthSort` is set to true.
  30917. * Each element of this array is an instance of the class DepthSortedParticle.
  30918. */
  30919. depthSortedParticles: DepthSortedParticle[];
  30920. /**
  30921. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30922. * @hidden
  30923. */
  30924. _bSphereOnly: boolean;
  30925. /**
  30926. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30927. * @hidden
  30928. */
  30929. _bSphereRadiusFactor: number;
  30930. private _scene;
  30931. private _positions;
  30932. private _indices;
  30933. private _normals;
  30934. private _colors;
  30935. private _uvs;
  30936. private _indices32;
  30937. private _positions32;
  30938. private _normals32;
  30939. private _fixedNormal32;
  30940. private _colors32;
  30941. private _uvs32;
  30942. private _index;
  30943. private _updatable;
  30944. private _pickable;
  30945. private _isVisibilityBoxLocked;
  30946. private _alwaysVisible;
  30947. private _depthSort;
  30948. private _expandable;
  30949. private _shapeCounter;
  30950. private _copy;
  30951. private _color;
  30952. private _computeParticleColor;
  30953. private _computeParticleTexture;
  30954. private _computeParticleRotation;
  30955. private _computeParticleVertex;
  30956. private _computeBoundingBox;
  30957. private _depthSortParticles;
  30958. private _camera;
  30959. private _mustUnrotateFixedNormals;
  30960. private _particlesIntersect;
  30961. private _needs32Bits;
  30962. private _isNotBuilt;
  30963. private _lastParticleId;
  30964. private _idxOfId;
  30965. private _multimaterialEnabled;
  30966. private _useModelMaterial;
  30967. private _indicesByMaterial;
  30968. private _materialIndexes;
  30969. private _depthSortFunction;
  30970. private _materialSortFunction;
  30971. private _materials;
  30972. private _multimaterial;
  30973. private _materialIndexesById;
  30974. private _defaultMaterial;
  30975. private _autoUpdateSubMeshes;
  30976. private _tmpVertex;
  30977. /**
  30978. * Creates a SPS (Solid Particle System) object.
  30979. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30980. * @param scene (Scene) is the scene in which the SPS is added.
  30981. * @param options defines the options of the sps e.g.
  30982. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30983. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30984. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30985. * * 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.
  30986. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30987. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30988. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30989. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30990. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30991. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30992. */
  30993. constructor(name: string, scene: Scene, options?: {
  30994. updatable?: boolean;
  30995. isPickable?: boolean;
  30996. enableDepthSort?: boolean;
  30997. particleIntersection?: boolean;
  30998. boundingSphereOnly?: boolean;
  30999. bSphereRadiusFactor?: number;
  31000. expandable?: boolean;
  31001. useModelMaterial?: boolean;
  31002. enableMultiMaterial?: boolean;
  31003. });
  31004. /**
  31005. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31006. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31007. * @returns the created mesh
  31008. */
  31009. buildMesh(): Mesh;
  31010. /**
  31011. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31012. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31013. * Thus the particles generated from `digest()` have their property `position` set yet.
  31014. * @param mesh ( Mesh ) is the mesh to be digested
  31015. * @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
  31016. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31017. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31018. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31019. * @returns the current SPS
  31020. */
  31021. digest(mesh: Mesh, options?: {
  31022. facetNb?: number;
  31023. number?: number;
  31024. delta?: number;
  31025. storage?: [];
  31026. }): SolidParticleSystem;
  31027. /**
  31028. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31029. * @hidden
  31030. */
  31031. private _unrotateFixedNormals;
  31032. /**
  31033. * Resets the temporary working copy particle
  31034. * @hidden
  31035. */
  31036. private _resetCopy;
  31037. /**
  31038. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31039. * @param p the current index in the positions array to be updated
  31040. * @param ind the current index in the indices array
  31041. * @param shape a Vector3 array, the shape geometry
  31042. * @param positions the positions array to be updated
  31043. * @param meshInd the shape indices array
  31044. * @param indices the indices array to be updated
  31045. * @param meshUV the shape uv array
  31046. * @param uvs the uv array to be updated
  31047. * @param meshCol the shape color array
  31048. * @param colors the color array to be updated
  31049. * @param meshNor the shape normals array
  31050. * @param normals the normals array to be updated
  31051. * @param idx the particle index
  31052. * @param idxInShape the particle index in its shape
  31053. * @param options the addShape() method passed options
  31054. * @model the particle model
  31055. * @hidden
  31056. */
  31057. private _meshBuilder;
  31058. /**
  31059. * Returns a shape Vector3 array from positions float array
  31060. * @param positions float array
  31061. * @returns a vector3 array
  31062. * @hidden
  31063. */
  31064. private _posToShape;
  31065. /**
  31066. * Returns a shapeUV array from a float uvs (array deep copy)
  31067. * @param uvs as a float array
  31068. * @returns a shapeUV array
  31069. * @hidden
  31070. */
  31071. private _uvsToShapeUV;
  31072. /**
  31073. * Adds a new particle object in the particles array
  31074. * @param idx particle index in particles array
  31075. * @param id particle id
  31076. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31077. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31078. * @param model particle ModelShape object
  31079. * @param shapeId model shape identifier
  31080. * @param idxInShape index of the particle in the current model
  31081. * @param bInfo model bounding info object
  31082. * @param storage target storage array, if any
  31083. * @hidden
  31084. */
  31085. private _addParticle;
  31086. /**
  31087. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31088. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31089. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31090. * @param nb (positive integer) the number of particles to be created from this model
  31091. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31092. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31093. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31094. * @returns the number of shapes in the system
  31095. */
  31096. addShape(mesh: Mesh, nb: number, options?: {
  31097. positionFunction?: any;
  31098. vertexFunction?: any;
  31099. storage?: [];
  31100. }): number;
  31101. /**
  31102. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31103. * @hidden
  31104. */
  31105. private _rebuildParticle;
  31106. /**
  31107. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31108. * @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.
  31109. * @returns the SPS.
  31110. */
  31111. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31112. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31113. * Returns an array with the removed particles.
  31114. * 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.
  31115. * The SPS can't be empty so at least one particle needs to remain in place.
  31116. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31117. * @param start index of the first particle to remove
  31118. * @param end index of the last particle to remove (included)
  31119. * @returns an array populated with the removed particles
  31120. */
  31121. removeParticles(start: number, end: number): SolidParticle[];
  31122. /**
  31123. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31124. * @param solidParticleArray an array populated with Solid Particles objects
  31125. * @returns the SPS
  31126. */
  31127. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31128. /**
  31129. * Creates a new particle and modifies the SPS mesh geometry :
  31130. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31131. * - calls _addParticle() to populate the particle array
  31132. * factorized code from addShape() and insertParticlesFromArray()
  31133. * @param idx particle index in the particles array
  31134. * @param i particle index in its shape
  31135. * @param modelShape particle ModelShape object
  31136. * @param shape shape vertex array
  31137. * @param meshInd shape indices array
  31138. * @param meshUV shape uv array
  31139. * @param meshCol shape color array
  31140. * @param meshNor shape normals array
  31141. * @param bbInfo shape bounding info
  31142. * @param storage target particle storage
  31143. * @options addShape() passed options
  31144. * @hidden
  31145. */
  31146. private _insertNewParticle;
  31147. /**
  31148. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31149. * This method calls `updateParticle()` for each particle of the SPS.
  31150. * For an animated SPS, it is usually called within the render loop.
  31151. * 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.
  31152. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31153. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31154. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31155. * @returns the SPS.
  31156. */
  31157. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31158. /**
  31159. * Disposes the SPS.
  31160. */
  31161. dispose(): void;
  31162. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31163. * idx is the particle index in the SPS
  31164. * faceId is the picked face index counted within this particle.
  31165. * Returns null if the pickInfo can't identify a picked particle.
  31166. * @param pickingInfo (PickingInfo object)
  31167. * @returns {idx: number, faceId: number} or null
  31168. */
  31169. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31170. idx: number;
  31171. faceId: number;
  31172. }>;
  31173. /**
  31174. * Returns a SolidParticle object from its identifier : particle.id
  31175. * @param id (integer) the particle Id
  31176. * @returns the searched particle or null if not found in the SPS.
  31177. */
  31178. getParticleById(id: number): Nullable<SolidParticle>;
  31179. /**
  31180. * Returns a new array populated with the particles having the passed shapeId.
  31181. * @param shapeId (integer) the shape identifier
  31182. * @returns a new solid particle array
  31183. */
  31184. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31185. /**
  31186. * Populates the passed array "ref" with the particles having the passed shapeId.
  31187. * @param shapeId the shape identifier
  31188. * @returns the SPS
  31189. * @param ref
  31190. */
  31191. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31192. /**
  31193. * Computes the required SubMeshes according the materials assigned to the particles.
  31194. * @returns the solid particle system.
  31195. * Does nothing if called before the SPS mesh is built.
  31196. */
  31197. computeSubMeshes(): SolidParticleSystem;
  31198. /**
  31199. * Sorts the solid particles by material when MultiMaterial is enabled.
  31200. * Updates the indices32 array.
  31201. * Updates the indicesByMaterial array.
  31202. * Updates the mesh indices array.
  31203. * @returns the SPS
  31204. * @hidden
  31205. */
  31206. private _sortParticlesByMaterial;
  31207. /**
  31208. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31209. * @hidden
  31210. */
  31211. private _setMaterialIndexesById;
  31212. /**
  31213. * Returns an array with unique values of Materials from the passed array
  31214. * @param array the material array to be checked and filtered
  31215. * @hidden
  31216. */
  31217. private _filterUniqueMaterialId;
  31218. /**
  31219. * Sets a new Standard Material as _defaultMaterial if not already set.
  31220. * @hidden
  31221. */
  31222. private _setDefaultMaterial;
  31223. /**
  31224. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31225. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31226. * @returns the SPS.
  31227. */
  31228. refreshVisibleSize(): SolidParticleSystem;
  31229. /**
  31230. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31231. * @param size the size (float) of the visibility box
  31232. * note : this doesn't lock the SPS mesh bounding box.
  31233. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31234. */
  31235. setVisibilityBox(size: number): void;
  31236. /**
  31237. * Gets whether the SPS as always visible or not
  31238. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31239. */
  31240. get isAlwaysVisible(): boolean;
  31241. /**
  31242. * Sets the SPS as always visible or not
  31243. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31244. */
  31245. set isAlwaysVisible(val: boolean);
  31246. /**
  31247. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31248. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31249. */
  31250. set isVisibilityBoxLocked(val: boolean);
  31251. /**
  31252. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31253. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31254. */
  31255. get isVisibilityBoxLocked(): boolean;
  31256. /**
  31257. * Tells to `setParticles()` to compute the particle rotations or not.
  31258. * Default value : true. The SPS is faster when it's set to false.
  31259. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31260. */
  31261. set computeParticleRotation(val: boolean);
  31262. /**
  31263. * Tells to `setParticles()` to compute the particle colors or not.
  31264. * Default value : true. The SPS is faster when it's set to false.
  31265. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31266. */
  31267. set computeParticleColor(val: boolean);
  31268. set computeParticleTexture(val: boolean);
  31269. /**
  31270. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31271. * Default value : false. The SPS is faster when it's set to false.
  31272. * Note : the particle custom vertex positions aren't stored values.
  31273. */
  31274. set computeParticleVertex(val: boolean);
  31275. /**
  31276. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31277. */
  31278. set computeBoundingBox(val: boolean);
  31279. /**
  31280. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31281. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31282. * Default : `true`
  31283. */
  31284. set depthSortParticles(val: boolean);
  31285. /**
  31286. * Gets if `setParticles()` computes the particle rotations or not.
  31287. * Default value : true. The SPS is faster when it's set to false.
  31288. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31289. */
  31290. get computeParticleRotation(): boolean;
  31291. /**
  31292. * Gets if `setParticles()` computes the particle colors or not.
  31293. * Default value : true. The SPS is faster when it's set to false.
  31294. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31295. */
  31296. get computeParticleColor(): boolean;
  31297. /**
  31298. * Gets if `setParticles()` computes the particle textures or not.
  31299. * Default value : true. The SPS is faster when it's set to false.
  31300. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31301. */
  31302. get computeParticleTexture(): boolean;
  31303. /**
  31304. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31305. * Default value : false. The SPS is faster when it's set to false.
  31306. * Note : the particle custom vertex positions aren't stored values.
  31307. */
  31308. get computeParticleVertex(): boolean;
  31309. /**
  31310. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31311. */
  31312. get computeBoundingBox(): boolean;
  31313. /**
  31314. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31315. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31316. * Default : `true`
  31317. */
  31318. get depthSortParticles(): boolean;
  31319. /**
  31320. * Gets if the SPS is created as expandable at construction time.
  31321. * Default : `false`
  31322. */
  31323. get expandable(): boolean;
  31324. /**
  31325. * Gets if the SPS supports the Multi Materials
  31326. */
  31327. get multimaterialEnabled(): boolean;
  31328. /**
  31329. * Gets if the SPS uses the model materials for its own multimaterial.
  31330. */
  31331. get useModelMaterial(): boolean;
  31332. /**
  31333. * The SPS used material array.
  31334. */
  31335. get materials(): Material[];
  31336. /**
  31337. * Sets the SPS MultiMaterial from the passed materials.
  31338. * Note : the passed array is internally copied and not used then by reference.
  31339. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31340. */
  31341. setMultiMaterial(materials: Material[]): void;
  31342. /**
  31343. * The SPS computed multimaterial object
  31344. */
  31345. get multimaterial(): MultiMaterial;
  31346. set multimaterial(mm: MultiMaterial);
  31347. /**
  31348. * If the subMeshes must be updated on the next call to setParticles()
  31349. */
  31350. get autoUpdateSubMeshes(): boolean;
  31351. set autoUpdateSubMeshes(val: boolean);
  31352. /**
  31353. * This function does nothing. It may be overwritten to set all the particle first values.
  31354. * The SPS doesn't call this function, you may have to call it by your own.
  31355. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31356. */
  31357. initParticles(): void;
  31358. /**
  31359. * This function does nothing. It may be overwritten to recycle a particle.
  31360. * The SPS doesn't call this function, you may have to call it by your own.
  31361. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31362. * @param particle The particle to recycle
  31363. * @returns the recycled particle
  31364. */
  31365. recycleParticle(particle: SolidParticle): SolidParticle;
  31366. /**
  31367. * Updates a particle : this function should be overwritten by the user.
  31368. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31369. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31370. * @example : just set a particle position or velocity and recycle conditions
  31371. * @param particle The particle to update
  31372. * @returns the updated particle
  31373. */
  31374. updateParticle(particle: SolidParticle): SolidParticle;
  31375. /**
  31376. * Updates a vertex of a particle : it can be overwritten by the user.
  31377. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31378. * @param particle the current particle
  31379. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31380. * @param pt the index of the current vertex in the particle shape
  31381. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31382. * @example : just set a vertex particle position or color
  31383. * @returns the sps
  31384. */
  31385. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31386. /**
  31387. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31388. * This does nothing and may be overwritten by the user.
  31389. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31390. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31391. * @param update the boolean update value actually passed to setParticles()
  31392. */
  31393. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31394. /**
  31395. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31396. * This will be passed three parameters.
  31397. * This does nothing and may be overwritten by the user.
  31398. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31399. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31400. * @param update the boolean update value actually passed to setParticles()
  31401. */
  31402. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31403. }
  31404. }
  31405. declare module BABYLON {
  31406. /**
  31407. * Represents one particle of a solid particle system.
  31408. */
  31409. export class SolidParticle {
  31410. /**
  31411. * particle global index
  31412. */
  31413. idx: number;
  31414. /**
  31415. * particle identifier
  31416. */
  31417. id: number;
  31418. /**
  31419. * The color of the particle
  31420. */
  31421. color: Nullable<Color4>;
  31422. /**
  31423. * The world space position of the particle.
  31424. */
  31425. position: Vector3;
  31426. /**
  31427. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31428. */
  31429. rotation: Vector3;
  31430. /**
  31431. * The world space rotation quaternion of the particle.
  31432. */
  31433. rotationQuaternion: Nullable<Quaternion>;
  31434. /**
  31435. * The scaling of the particle.
  31436. */
  31437. scaling: Vector3;
  31438. /**
  31439. * The uvs of the particle.
  31440. */
  31441. uvs: Vector4;
  31442. /**
  31443. * The current speed of the particle.
  31444. */
  31445. velocity: Vector3;
  31446. /**
  31447. * The pivot point in the particle local space.
  31448. */
  31449. pivot: Vector3;
  31450. /**
  31451. * Must the particle be translated from its pivot point in its local space ?
  31452. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31453. * Default : false
  31454. */
  31455. translateFromPivot: boolean;
  31456. /**
  31457. * Is the particle active or not ?
  31458. */
  31459. alive: boolean;
  31460. /**
  31461. * Is the particle visible or not ?
  31462. */
  31463. isVisible: boolean;
  31464. /**
  31465. * Index of this particle in the global "positions" array (Internal use)
  31466. * @hidden
  31467. */
  31468. _pos: number;
  31469. /**
  31470. * @hidden Index of this particle in the global "indices" array (Internal use)
  31471. */
  31472. _ind: number;
  31473. /**
  31474. * @hidden ModelShape of this particle (Internal use)
  31475. */
  31476. _model: ModelShape;
  31477. /**
  31478. * ModelShape id of this particle
  31479. */
  31480. shapeId: number;
  31481. /**
  31482. * Index of the particle in its shape id
  31483. */
  31484. idxInShape: number;
  31485. /**
  31486. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31487. */
  31488. _modelBoundingInfo: BoundingInfo;
  31489. /**
  31490. * @hidden Particle BoundingInfo object (Internal use)
  31491. */
  31492. _boundingInfo: BoundingInfo;
  31493. /**
  31494. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31495. */
  31496. _sps: SolidParticleSystem;
  31497. /**
  31498. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31499. */
  31500. _stillInvisible: boolean;
  31501. /**
  31502. * @hidden Last computed particle rotation matrix
  31503. */
  31504. _rotationMatrix: number[];
  31505. /**
  31506. * Parent particle Id, if any.
  31507. * Default null.
  31508. */
  31509. parentId: Nullable<number>;
  31510. /**
  31511. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31512. */
  31513. materialIndex: Nullable<number>;
  31514. /**
  31515. * Custom object or properties.
  31516. */
  31517. props: Nullable<any>;
  31518. /**
  31519. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31520. * The possible values are :
  31521. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31522. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31523. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31524. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31525. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31526. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31527. * */
  31528. cullingStrategy: number;
  31529. /**
  31530. * @hidden Internal global position in the SPS.
  31531. */
  31532. _globalPosition: Vector3;
  31533. /**
  31534. * Creates a Solid Particle object.
  31535. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31536. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31537. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31538. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31539. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31540. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31541. * @param shapeId (integer) is the model shape identifier in the SPS.
  31542. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31543. * @param sps defines the sps it is associated to
  31544. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31545. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31546. */
  31547. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31548. /**
  31549. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31550. * @param target the particle target
  31551. * @returns the current particle
  31552. */
  31553. copyToRef(target: SolidParticle): SolidParticle;
  31554. /**
  31555. * Legacy support, changed scale to scaling
  31556. */
  31557. get scale(): Vector3;
  31558. /**
  31559. * Legacy support, changed scale to scaling
  31560. */
  31561. set scale(scale: Vector3);
  31562. /**
  31563. * Legacy support, changed quaternion to rotationQuaternion
  31564. */
  31565. get quaternion(): Nullable<Quaternion>;
  31566. /**
  31567. * Legacy support, changed quaternion to rotationQuaternion
  31568. */
  31569. set quaternion(q: Nullable<Quaternion>);
  31570. /**
  31571. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31572. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31573. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31574. * @returns true if it intersects
  31575. */
  31576. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31577. /**
  31578. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31579. * A particle is in the frustum if its bounding box intersects the frustum
  31580. * @param frustumPlanes defines the frustum to test
  31581. * @returns true if the particle is in the frustum planes
  31582. */
  31583. isInFrustum(frustumPlanes: Plane[]): boolean;
  31584. /**
  31585. * get the rotation matrix of the particle
  31586. * @hidden
  31587. */
  31588. getRotationMatrix(m: Matrix): void;
  31589. }
  31590. /**
  31591. * Represents the shape of the model used by one particle of a solid particle system.
  31592. * SPS internal tool, don't use it manually.
  31593. */
  31594. export class ModelShape {
  31595. /**
  31596. * The shape id
  31597. * @hidden
  31598. */
  31599. shapeID: number;
  31600. /**
  31601. * flat array of model positions (internal use)
  31602. * @hidden
  31603. */
  31604. _shape: Vector3[];
  31605. /**
  31606. * flat array of model UVs (internal use)
  31607. * @hidden
  31608. */
  31609. _shapeUV: number[];
  31610. /**
  31611. * color array of the model
  31612. * @hidden
  31613. */
  31614. _shapeColors: number[];
  31615. /**
  31616. * indices array of the model
  31617. * @hidden
  31618. */
  31619. _indices: number[];
  31620. /**
  31621. * normals array of the model
  31622. * @hidden
  31623. */
  31624. _normals: number[];
  31625. /**
  31626. * length of the shape in the model indices array (internal use)
  31627. * @hidden
  31628. */
  31629. _indicesLength: number;
  31630. /**
  31631. * Custom position function (internal use)
  31632. * @hidden
  31633. */
  31634. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31635. /**
  31636. * Custom vertex function (internal use)
  31637. * @hidden
  31638. */
  31639. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31640. /**
  31641. * Model material (internal use)
  31642. * @hidden
  31643. */
  31644. _material: Nullable<Material>;
  31645. /**
  31646. * 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.
  31647. * SPS internal tool, don't use it manually.
  31648. * @hidden
  31649. */
  31650. 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>);
  31651. }
  31652. /**
  31653. * Represents a Depth Sorted Particle in the solid particle system.
  31654. * @hidden
  31655. */
  31656. export class DepthSortedParticle {
  31657. /**
  31658. * Particle index
  31659. */
  31660. idx: number;
  31661. /**
  31662. * Index of the particle in the "indices" array
  31663. */
  31664. ind: number;
  31665. /**
  31666. * Length of the particle shape in the "indices" array
  31667. */
  31668. indicesLength: number;
  31669. /**
  31670. * Squared distance from the particle to the camera
  31671. */
  31672. sqDistance: number;
  31673. /**
  31674. * Material index when used with MultiMaterials
  31675. */
  31676. materialIndex: number;
  31677. /**
  31678. * Creates a new sorted particle
  31679. * @param materialIndex
  31680. */
  31681. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31682. }
  31683. /**
  31684. * Represents a solid particle vertex
  31685. */
  31686. export class SolidParticleVertex {
  31687. /**
  31688. * Vertex position
  31689. */
  31690. position: Vector3;
  31691. /**
  31692. * Vertex color
  31693. */
  31694. color: Color4;
  31695. /**
  31696. * Vertex UV
  31697. */
  31698. uv: Vector2;
  31699. /**
  31700. * Creates a new solid particle vertex
  31701. */
  31702. constructor();
  31703. /** Vertex x coordinate */
  31704. get x(): number;
  31705. set x(val: number);
  31706. /** Vertex y coordinate */
  31707. get y(): number;
  31708. set y(val: number);
  31709. /** Vertex z coordinate */
  31710. get z(): number;
  31711. set z(val: number);
  31712. }
  31713. }
  31714. declare module BABYLON {
  31715. /**
  31716. * @hidden
  31717. */
  31718. export class _MeshCollisionData {
  31719. _checkCollisions: boolean;
  31720. _collisionMask: number;
  31721. _collisionGroup: number;
  31722. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31723. _collider: Nullable<Collider>;
  31724. _oldPositionForCollisions: Vector3;
  31725. _diffPositionForCollisions: Vector3;
  31726. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31727. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31728. }
  31729. }
  31730. declare module BABYLON {
  31731. /** @hidden */
  31732. class _FacetDataStorage {
  31733. facetPositions: Vector3[];
  31734. facetNormals: Vector3[];
  31735. facetPartitioning: number[][];
  31736. facetNb: number;
  31737. partitioningSubdivisions: number;
  31738. partitioningBBoxRatio: number;
  31739. facetDataEnabled: boolean;
  31740. facetParameters: any;
  31741. bbSize: Vector3;
  31742. subDiv: {
  31743. max: number;
  31744. X: number;
  31745. Y: number;
  31746. Z: number;
  31747. };
  31748. facetDepthSort: boolean;
  31749. facetDepthSortEnabled: boolean;
  31750. depthSortedIndices: IndicesArray;
  31751. depthSortedFacets: {
  31752. ind: number;
  31753. sqDistance: number;
  31754. }[];
  31755. facetDepthSortFunction: (f1: {
  31756. ind: number;
  31757. sqDistance: number;
  31758. }, f2: {
  31759. ind: number;
  31760. sqDistance: number;
  31761. }) => number;
  31762. facetDepthSortFrom: Vector3;
  31763. facetDepthSortOrigin: Vector3;
  31764. invertedMatrix: Matrix;
  31765. }
  31766. /**
  31767. * @hidden
  31768. **/
  31769. class _InternalAbstractMeshDataInfo {
  31770. _hasVertexAlpha: boolean;
  31771. _useVertexColors: boolean;
  31772. _numBoneInfluencers: number;
  31773. _applyFog: boolean;
  31774. _receiveShadows: boolean;
  31775. _facetData: _FacetDataStorage;
  31776. _visibility: number;
  31777. _skeleton: Nullable<Skeleton>;
  31778. _layerMask: number;
  31779. _computeBonesUsingShaders: boolean;
  31780. _isActive: boolean;
  31781. _onlyForInstances: boolean;
  31782. _isActiveIntermediate: boolean;
  31783. _onlyForInstancesIntermediate: boolean;
  31784. _actAsRegularMesh: boolean;
  31785. }
  31786. /**
  31787. * Class used to store all common mesh properties
  31788. */
  31789. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31790. /** No occlusion */
  31791. static OCCLUSION_TYPE_NONE: number;
  31792. /** Occlusion set to optimisitic */
  31793. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31794. /** Occlusion set to strict */
  31795. static OCCLUSION_TYPE_STRICT: number;
  31796. /** Use an accurante occlusion algorithm */
  31797. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31798. /** Use a conservative occlusion algorithm */
  31799. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31800. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31801. * Test order :
  31802. * Is the bounding sphere outside the frustum ?
  31803. * If not, are the bounding box vertices outside the frustum ?
  31804. * It not, then the cullable object is in the frustum.
  31805. */
  31806. static readonly CULLINGSTRATEGY_STANDARD: number;
  31807. /** Culling strategy : Bounding Sphere Only.
  31808. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31809. * It's also less accurate than the standard because some not visible objects can still be selected.
  31810. * Test : is the bounding sphere outside the frustum ?
  31811. * If not, then the cullable object is in the frustum.
  31812. */
  31813. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31814. /** Culling strategy : Optimistic Inclusion.
  31815. * This in an inclusion test first, then the standard exclusion test.
  31816. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31817. * 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.
  31818. * Anyway, it's as accurate as the standard strategy.
  31819. * Test :
  31820. * Is the cullable object bounding sphere center in the frustum ?
  31821. * If not, apply the default culling strategy.
  31822. */
  31823. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31824. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31825. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31826. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31827. * 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.
  31828. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31829. * Test :
  31830. * Is the cullable object bounding sphere center in the frustum ?
  31831. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31832. */
  31833. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31834. /**
  31835. * No billboard
  31836. */
  31837. static get BILLBOARDMODE_NONE(): number;
  31838. /** Billboard on X axis */
  31839. static get BILLBOARDMODE_X(): number;
  31840. /** Billboard on Y axis */
  31841. static get BILLBOARDMODE_Y(): number;
  31842. /** Billboard on Z axis */
  31843. static get BILLBOARDMODE_Z(): number;
  31844. /** Billboard on all axes */
  31845. static get BILLBOARDMODE_ALL(): number;
  31846. /** Billboard on using position instead of orientation */
  31847. static get BILLBOARDMODE_USE_POSITION(): number;
  31848. /** @hidden */
  31849. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31850. /**
  31851. * The culling strategy to use to check whether the mesh must be rendered or not.
  31852. * This value can be changed at any time and will be used on the next render mesh selection.
  31853. * The possible values are :
  31854. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31855. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31856. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31857. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31858. * Please read each static variable documentation to get details about the culling process.
  31859. * */
  31860. cullingStrategy: number;
  31861. /**
  31862. * Gets the number of facets in the mesh
  31863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31864. */
  31865. get facetNb(): number;
  31866. /**
  31867. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31868. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31869. */
  31870. get partitioningSubdivisions(): number;
  31871. set partitioningSubdivisions(nb: number);
  31872. /**
  31873. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31874. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31875. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31876. */
  31877. get partitioningBBoxRatio(): number;
  31878. set partitioningBBoxRatio(ratio: number);
  31879. /**
  31880. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31881. * Works only for updatable meshes.
  31882. * Doesn't work with multi-materials
  31883. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31884. */
  31885. get mustDepthSortFacets(): boolean;
  31886. set mustDepthSortFacets(sort: boolean);
  31887. /**
  31888. * The location (Vector3) where the facet depth sort must be computed from.
  31889. * By default, the active camera position.
  31890. * Used only when facet depth sort is enabled
  31891. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31892. */
  31893. get facetDepthSortFrom(): Vector3;
  31894. set facetDepthSortFrom(location: Vector3);
  31895. /**
  31896. * gets a boolean indicating if facetData is enabled
  31897. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31898. */
  31899. get isFacetDataEnabled(): boolean;
  31900. /** @hidden */
  31901. _updateNonUniformScalingState(value: boolean): boolean;
  31902. /**
  31903. * An event triggered when this mesh collides with another one
  31904. */
  31905. onCollideObservable: Observable<AbstractMesh>;
  31906. /** Set a function to call when this mesh collides with another one */
  31907. set onCollide(callback: () => void);
  31908. /**
  31909. * An event triggered when the collision's position changes
  31910. */
  31911. onCollisionPositionChangeObservable: Observable<Vector3>;
  31912. /** Set a function to call when the collision's position changes */
  31913. set onCollisionPositionChange(callback: () => void);
  31914. /**
  31915. * An event triggered when material is changed
  31916. */
  31917. onMaterialChangedObservable: Observable<AbstractMesh>;
  31918. /**
  31919. * Gets or sets the orientation for POV movement & rotation
  31920. */
  31921. definedFacingForward: boolean;
  31922. /** @hidden */
  31923. _occlusionQuery: Nullable<WebGLQuery>;
  31924. /** @hidden */
  31925. _renderingGroup: Nullable<RenderingGroup>;
  31926. /**
  31927. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31928. */
  31929. get visibility(): number;
  31930. /**
  31931. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31932. */
  31933. set visibility(value: number);
  31934. /** Gets or sets the alpha index used to sort transparent meshes
  31935. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31936. */
  31937. alphaIndex: number;
  31938. /**
  31939. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31940. */
  31941. isVisible: boolean;
  31942. /**
  31943. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31944. */
  31945. isPickable: boolean;
  31946. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31947. showSubMeshesBoundingBox: boolean;
  31948. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31949. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31950. */
  31951. isBlocker: boolean;
  31952. /**
  31953. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31954. */
  31955. enablePointerMoveEvents: boolean;
  31956. /**
  31957. * Specifies the rendering group id for this mesh (0 by default)
  31958. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31959. */
  31960. renderingGroupId: number;
  31961. private _material;
  31962. /** Gets or sets current material */
  31963. get material(): Nullable<Material>;
  31964. set material(value: Nullable<Material>);
  31965. /**
  31966. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31967. * @see https://doc.babylonjs.com/babylon101/shadows
  31968. */
  31969. get receiveShadows(): boolean;
  31970. set receiveShadows(value: boolean);
  31971. /** Defines color to use when rendering outline */
  31972. outlineColor: Color3;
  31973. /** Define width to use when rendering outline */
  31974. outlineWidth: number;
  31975. /** Defines color to use when rendering overlay */
  31976. overlayColor: Color3;
  31977. /** Defines alpha to use when rendering overlay */
  31978. overlayAlpha: number;
  31979. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31980. get hasVertexAlpha(): boolean;
  31981. set hasVertexAlpha(value: boolean);
  31982. /** 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) */
  31983. get useVertexColors(): boolean;
  31984. set useVertexColors(value: boolean);
  31985. /**
  31986. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31987. */
  31988. get computeBonesUsingShaders(): boolean;
  31989. set computeBonesUsingShaders(value: boolean);
  31990. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31991. get numBoneInfluencers(): number;
  31992. set numBoneInfluencers(value: number);
  31993. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31994. get applyFog(): boolean;
  31995. set applyFog(value: boolean);
  31996. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31997. useOctreeForRenderingSelection: boolean;
  31998. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31999. useOctreeForPicking: boolean;
  32000. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32001. useOctreeForCollisions: boolean;
  32002. /**
  32003. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32004. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32005. */
  32006. get layerMask(): number;
  32007. set layerMask(value: number);
  32008. /**
  32009. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32010. */
  32011. alwaysSelectAsActiveMesh: boolean;
  32012. /**
  32013. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32014. */
  32015. doNotSyncBoundingInfo: boolean;
  32016. /**
  32017. * Gets or sets the current action manager
  32018. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32019. */
  32020. actionManager: Nullable<AbstractActionManager>;
  32021. private _meshCollisionData;
  32022. /**
  32023. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32024. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32025. */
  32026. ellipsoid: Vector3;
  32027. /**
  32028. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32029. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32030. */
  32031. ellipsoidOffset: Vector3;
  32032. /**
  32033. * Gets or sets a collision mask used to mask collisions (default is -1).
  32034. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32035. */
  32036. get collisionMask(): number;
  32037. set collisionMask(mask: number);
  32038. /**
  32039. * Gets or sets the current collision group mask (-1 by default).
  32040. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32041. */
  32042. get collisionGroup(): number;
  32043. set collisionGroup(mask: number);
  32044. /**
  32045. * Gets or sets current surrounding meshes (null by default).
  32046. *
  32047. * By default collision detection is tested against every mesh in the scene.
  32048. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32049. * meshes will be tested for the collision.
  32050. *
  32051. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32052. */
  32053. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32054. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32055. /**
  32056. * Defines edge width used when edgesRenderer is enabled
  32057. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32058. */
  32059. edgesWidth: number;
  32060. /**
  32061. * Defines edge color used when edgesRenderer is enabled
  32062. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32063. */
  32064. edgesColor: Color4;
  32065. /** @hidden */
  32066. _edgesRenderer: Nullable<IEdgesRenderer>;
  32067. /** @hidden */
  32068. _masterMesh: Nullable<AbstractMesh>;
  32069. /** @hidden */
  32070. _boundingInfo: Nullable<BoundingInfo>;
  32071. /** @hidden */
  32072. _renderId: number;
  32073. /**
  32074. * Gets or sets the list of subMeshes
  32075. * @see https://doc.babylonjs.com/how_to/multi_materials
  32076. */
  32077. subMeshes: SubMesh[];
  32078. /** @hidden */
  32079. _intersectionsInProgress: AbstractMesh[];
  32080. /** @hidden */
  32081. _unIndexed: boolean;
  32082. /** @hidden */
  32083. _lightSources: Light[];
  32084. /** Gets the list of lights affecting that mesh */
  32085. get lightSources(): Light[];
  32086. /** @hidden */
  32087. get _positions(): Nullable<Vector3[]>;
  32088. /** @hidden */
  32089. _waitingData: {
  32090. lods: Nullable<any>;
  32091. actions: Nullable<any>;
  32092. freezeWorldMatrix: Nullable<boolean>;
  32093. };
  32094. /** @hidden */
  32095. _bonesTransformMatrices: Nullable<Float32Array>;
  32096. /** @hidden */
  32097. _transformMatrixTexture: Nullable<RawTexture>;
  32098. /**
  32099. * Gets or sets a skeleton to apply skining transformations
  32100. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32101. */
  32102. set skeleton(value: Nullable<Skeleton>);
  32103. get skeleton(): Nullable<Skeleton>;
  32104. /**
  32105. * An event triggered when the mesh is rebuilt.
  32106. */
  32107. onRebuildObservable: Observable<AbstractMesh>;
  32108. /**
  32109. * Creates a new AbstractMesh
  32110. * @param name defines the name of the mesh
  32111. * @param scene defines the hosting scene
  32112. */
  32113. constructor(name: string, scene?: Nullable<Scene>);
  32114. /**
  32115. * Returns the string "AbstractMesh"
  32116. * @returns "AbstractMesh"
  32117. */
  32118. getClassName(): string;
  32119. /**
  32120. * Gets a string representation of the current mesh
  32121. * @param fullDetails defines a boolean indicating if full details must be included
  32122. * @returns a string representation of the current mesh
  32123. */
  32124. toString(fullDetails?: boolean): string;
  32125. /**
  32126. * @hidden
  32127. */
  32128. protected _getEffectiveParent(): Nullable<Node>;
  32129. /** @hidden */
  32130. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32131. /** @hidden */
  32132. _rebuild(): void;
  32133. /** @hidden */
  32134. _resyncLightSources(): void;
  32135. /** @hidden */
  32136. _resyncLightSource(light: Light): void;
  32137. /** @hidden */
  32138. _unBindEffect(): void;
  32139. /** @hidden */
  32140. _removeLightSource(light: Light, dispose: boolean): void;
  32141. private _markSubMeshesAsDirty;
  32142. /** @hidden */
  32143. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32144. /** @hidden */
  32145. _markSubMeshesAsAttributesDirty(): void;
  32146. /** @hidden */
  32147. _markSubMeshesAsMiscDirty(): void;
  32148. /**
  32149. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32150. */
  32151. get scaling(): Vector3;
  32152. set scaling(newScaling: Vector3);
  32153. /**
  32154. * Returns true if the mesh is blocked. Implemented by child classes
  32155. */
  32156. get isBlocked(): boolean;
  32157. /**
  32158. * Returns the mesh itself by default. Implemented by child classes
  32159. * @param camera defines the camera to use to pick the right LOD level
  32160. * @returns the currentAbstractMesh
  32161. */
  32162. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32163. /**
  32164. * Returns 0 by default. Implemented by child classes
  32165. * @returns an integer
  32166. */
  32167. getTotalVertices(): number;
  32168. /**
  32169. * Returns a positive integer : the total number of indices in this mesh geometry.
  32170. * @returns the numner of indices or zero if the mesh has no geometry.
  32171. */
  32172. getTotalIndices(): number;
  32173. /**
  32174. * Returns null by default. Implemented by child classes
  32175. * @returns null
  32176. */
  32177. getIndices(): Nullable<IndicesArray>;
  32178. /**
  32179. * Returns the array of the requested vertex data kind. Implemented by child classes
  32180. * @param kind defines the vertex data kind to use
  32181. * @returns null
  32182. */
  32183. getVerticesData(kind: string): Nullable<FloatArray>;
  32184. /**
  32185. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32186. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32187. * Note that a new underlying VertexBuffer object is created each call.
  32188. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32189. * @param kind defines vertex data kind:
  32190. * * VertexBuffer.PositionKind
  32191. * * VertexBuffer.UVKind
  32192. * * VertexBuffer.UV2Kind
  32193. * * VertexBuffer.UV3Kind
  32194. * * VertexBuffer.UV4Kind
  32195. * * VertexBuffer.UV5Kind
  32196. * * VertexBuffer.UV6Kind
  32197. * * VertexBuffer.ColorKind
  32198. * * VertexBuffer.MatricesIndicesKind
  32199. * * VertexBuffer.MatricesIndicesExtraKind
  32200. * * VertexBuffer.MatricesWeightsKind
  32201. * * VertexBuffer.MatricesWeightsExtraKind
  32202. * @param data defines the data source
  32203. * @param updatable defines if the data must be flagged as updatable (or static)
  32204. * @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
  32205. * @returns the current mesh
  32206. */
  32207. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32208. /**
  32209. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32210. * If the mesh has no geometry, it is simply returned as it is.
  32211. * @param kind defines vertex data kind:
  32212. * * VertexBuffer.PositionKind
  32213. * * VertexBuffer.UVKind
  32214. * * VertexBuffer.UV2Kind
  32215. * * VertexBuffer.UV3Kind
  32216. * * VertexBuffer.UV4Kind
  32217. * * VertexBuffer.UV5Kind
  32218. * * VertexBuffer.UV6Kind
  32219. * * VertexBuffer.ColorKind
  32220. * * VertexBuffer.MatricesIndicesKind
  32221. * * VertexBuffer.MatricesIndicesExtraKind
  32222. * * VertexBuffer.MatricesWeightsKind
  32223. * * VertexBuffer.MatricesWeightsExtraKind
  32224. * @param data defines the data source
  32225. * @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
  32226. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32227. * @returns the current mesh
  32228. */
  32229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32230. /**
  32231. * Sets the mesh indices,
  32232. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32233. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32234. * @param totalVertices Defines the total number of vertices
  32235. * @returns the current mesh
  32236. */
  32237. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32238. /**
  32239. * Gets a boolean indicating if specific vertex data is present
  32240. * @param kind defines the vertex data kind to use
  32241. * @returns true is data kind is present
  32242. */
  32243. isVerticesDataPresent(kind: string): boolean;
  32244. /**
  32245. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32246. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32247. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32248. * @returns a BoundingInfo
  32249. */
  32250. getBoundingInfo(): BoundingInfo;
  32251. /**
  32252. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32253. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32254. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32255. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32256. * @returns the current mesh
  32257. */
  32258. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32259. /**
  32260. * Overwrite the current bounding info
  32261. * @param boundingInfo defines the new bounding info
  32262. * @returns the current mesh
  32263. */
  32264. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32265. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32266. get useBones(): boolean;
  32267. /** @hidden */
  32268. _preActivate(): void;
  32269. /** @hidden */
  32270. _preActivateForIntermediateRendering(renderId: number): void;
  32271. /** @hidden */
  32272. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32273. /** @hidden */
  32274. _postActivate(): void;
  32275. /** @hidden */
  32276. _freeze(): void;
  32277. /** @hidden */
  32278. _unFreeze(): void;
  32279. /**
  32280. * Gets the current world matrix
  32281. * @returns a Matrix
  32282. */
  32283. getWorldMatrix(): Matrix;
  32284. /** @hidden */
  32285. _getWorldMatrixDeterminant(): number;
  32286. /**
  32287. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32288. */
  32289. get isAnInstance(): boolean;
  32290. /**
  32291. * Gets a boolean indicating if this mesh has instances
  32292. */
  32293. get hasInstances(): boolean;
  32294. /**
  32295. * Gets a boolean indicating if this mesh has thin instances
  32296. */
  32297. get hasThinInstances(): boolean;
  32298. /**
  32299. * Perform relative position change from the point of view of behind the front of the mesh.
  32300. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32301. * Supports definition of mesh facing forward or backward
  32302. * @param amountRight defines the distance on the right axis
  32303. * @param amountUp defines the distance on the up axis
  32304. * @param amountForward defines the distance on the forward axis
  32305. * @returns the current mesh
  32306. */
  32307. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32308. /**
  32309. * Calculate relative position change from the point of view of behind the front of the mesh.
  32310. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32311. * Supports definition of mesh facing forward or backward
  32312. * @param amountRight defines the distance on the right axis
  32313. * @param amountUp defines the distance on the up axis
  32314. * @param amountForward defines the distance on the forward axis
  32315. * @returns the new displacement vector
  32316. */
  32317. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32318. /**
  32319. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32320. * Supports definition of mesh facing forward or backward
  32321. * @param flipBack defines the flip
  32322. * @param twirlClockwise defines the twirl
  32323. * @param tiltRight defines the tilt
  32324. * @returns the current mesh
  32325. */
  32326. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32327. /**
  32328. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32329. * Supports definition of mesh facing forward or backward.
  32330. * @param flipBack defines the flip
  32331. * @param twirlClockwise defines the twirl
  32332. * @param tiltRight defines the tilt
  32333. * @returns the new rotation vector
  32334. */
  32335. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32336. /**
  32337. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32338. * This means the mesh underlying bounding box and sphere are recomputed.
  32339. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32340. * @returns the current mesh
  32341. */
  32342. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32343. /** @hidden */
  32344. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32345. /** @hidden */
  32346. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32347. /** @hidden */
  32348. _updateBoundingInfo(): AbstractMesh;
  32349. /** @hidden */
  32350. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32351. /** @hidden */
  32352. protected _afterComputeWorldMatrix(): void;
  32353. /** @hidden */
  32354. get _effectiveMesh(): AbstractMesh;
  32355. /**
  32356. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32357. * A mesh is in the frustum if its bounding box intersects the frustum
  32358. * @param frustumPlanes defines the frustum to test
  32359. * @returns true if the mesh is in the frustum planes
  32360. */
  32361. isInFrustum(frustumPlanes: Plane[]): boolean;
  32362. /**
  32363. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32364. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32365. * @param frustumPlanes defines the frustum to test
  32366. * @returns true if the mesh is completely in the frustum planes
  32367. */
  32368. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32369. /**
  32370. * True if the mesh intersects another mesh or a SolidParticle object
  32371. * @param mesh defines a target mesh or SolidParticle to test
  32372. * @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)
  32373. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32374. * @returns true if there is an intersection
  32375. */
  32376. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32377. /**
  32378. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32379. * @param point defines the point to test
  32380. * @returns true if there is an intersection
  32381. */
  32382. intersectsPoint(point: Vector3): boolean;
  32383. /**
  32384. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32385. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32386. */
  32387. get checkCollisions(): boolean;
  32388. set checkCollisions(collisionEnabled: boolean);
  32389. /**
  32390. * Gets Collider object used to compute collisions (not physics)
  32391. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32392. */
  32393. get collider(): Nullable<Collider>;
  32394. /**
  32395. * Move the mesh using collision engine
  32396. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32397. * @param displacement defines the requested displacement vector
  32398. * @returns the current mesh
  32399. */
  32400. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32401. private _onCollisionPositionChange;
  32402. /** @hidden */
  32403. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32404. /** @hidden */
  32405. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32406. /** @hidden */
  32407. _checkCollision(collider: Collider): AbstractMesh;
  32408. /** @hidden */
  32409. _generatePointsArray(): boolean;
  32410. /**
  32411. * Checks if the passed Ray intersects with the mesh
  32412. * @param ray defines the ray to use
  32413. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32414. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32415. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32416. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32417. * @returns the picking info
  32418. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32419. */
  32420. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32421. /**
  32422. * Clones the current mesh
  32423. * @param name defines the mesh name
  32424. * @param newParent defines the new mesh parent
  32425. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32426. * @returns the new mesh
  32427. */
  32428. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32429. /**
  32430. * Disposes all the submeshes of the current meshnp
  32431. * @returns the current mesh
  32432. */
  32433. releaseSubMeshes(): AbstractMesh;
  32434. /**
  32435. * Releases resources associated with this abstract mesh.
  32436. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32437. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32438. */
  32439. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32440. /**
  32441. * Adds the passed mesh as a child to the current mesh
  32442. * @param mesh defines the child mesh
  32443. * @returns the current mesh
  32444. */
  32445. addChild(mesh: AbstractMesh): AbstractMesh;
  32446. /**
  32447. * Removes the passed mesh from the current mesh children list
  32448. * @param mesh defines the child mesh
  32449. * @returns the current mesh
  32450. */
  32451. removeChild(mesh: AbstractMesh): AbstractMesh;
  32452. /** @hidden */
  32453. private _initFacetData;
  32454. /**
  32455. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32456. * This method can be called within the render loop.
  32457. * 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
  32458. * @returns the current mesh
  32459. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32460. */
  32461. updateFacetData(): AbstractMesh;
  32462. /**
  32463. * Returns the facetLocalNormals array.
  32464. * The normals are expressed in the mesh local spac
  32465. * @returns an array of Vector3
  32466. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32467. */
  32468. getFacetLocalNormals(): Vector3[];
  32469. /**
  32470. * Returns the facetLocalPositions array.
  32471. * The facet positions are expressed in the mesh local space
  32472. * @returns an array of Vector3
  32473. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32474. */
  32475. getFacetLocalPositions(): Vector3[];
  32476. /**
  32477. * Returns the facetLocalPartioning array
  32478. * @returns an array of array of numbers
  32479. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32480. */
  32481. getFacetLocalPartitioning(): number[][];
  32482. /**
  32483. * Returns the i-th facet position in the world system.
  32484. * This method allocates a new Vector3 per call
  32485. * @param i defines the facet index
  32486. * @returns a new Vector3
  32487. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32488. */
  32489. getFacetPosition(i: number): Vector3;
  32490. /**
  32491. * Sets the reference Vector3 with the i-th facet position in the world system
  32492. * @param i defines the facet index
  32493. * @param ref defines the target vector
  32494. * @returns the current mesh
  32495. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32496. */
  32497. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32498. /**
  32499. * Returns the i-th facet normal in the world system.
  32500. * This method allocates a new Vector3 per call
  32501. * @param i defines the facet index
  32502. * @returns a new Vector3
  32503. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32504. */
  32505. getFacetNormal(i: number): Vector3;
  32506. /**
  32507. * Sets the reference Vector3 with the i-th facet normal in the world system
  32508. * @param i defines the facet index
  32509. * @param ref defines the target vector
  32510. * @returns the current mesh
  32511. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32512. */
  32513. getFacetNormalToRef(i: number, ref: Vector3): this;
  32514. /**
  32515. * 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)
  32516. * @param x defines x coordinate
  32517. * @param y defines y coordinate
  32518. * @param z defines z coordinate
  32519. * @returns the array of facet indexes
  32520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32521. */
  32522. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32523. /**
  32524. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32525. * @param projected sets as the (x,y,z) world projection on the facet
  32526. * @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
  32527. * @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
  32528. * @param x defines x coordinate
  32529. * @param y defines y coordinate
  32530. * @param z defines z coordinate
  32531. * @returns the face index if found (or null instead)
  32532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32533. */
  32534. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32535. /**
  32536. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32537. * @param projected sets as the (x,y,z) local projection on the facet
  32538. * @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
  32539. * @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
  32540. * @param x defines x coordinate
  32541. * @param y defines y coordinate
  32542. * @param z defines z coordinate
  32543. * @returns the face index if found (or null instead)
  32544. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32545. */
  32546. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32547. /**
  32548. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32549. * @returns the parameters
  32550. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32551. */
  32552. getFacetDataParameters(): any;
  32553. /**
  32554. * Disables the feature FacetData and frees the related memory
  32555. * @returns the current mesh
  32556. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32557. */
  32558. disableFacetData(): AbstractMesh;
  32559. /**
  32560. * Updates the AbstractMesh indices array
  32561. * @param indices defines the data source
  32562. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32563. * @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)
  32564. * @returns the current mesh
  32565. */
  32566. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32567. /**
  32568. * Creates new normals data for the mesh
  32569. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32570. * @returns the current mesh
  32571. */
  32572. createNormals(updatable: boolean): AbstractMesh;
  32573. /**
  32574. * Align the mesh with a normal
  32575. * @param normal defines the normal to use
  32576. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32577. * @returns the current mesh
  32578. */
  32579. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32580. /** @hidden */
  32581. _checkOcclusionQuery(): boolean;
  32582. /**
  32583. * Disables the mesh edge rendering mode
  32584. * @returns the currentAbstractMesh
  32585. */
  32586. disableEdgesRendering(): AbstractMesh;
  32587. /**
  32588. * Enables the edge rendering mode on the mesh.
  32589. * This mode makes the mesh edges visible
  32590. * @param epsilon defines the maximal distance between two angles to detect a face
  32591. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32592. * @returns the currentAbstractMesh
  32593. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32594. */
  32595. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32596. /**
  32597. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32598. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32599. */
  32600. getConnectedParticleSystems(): IParticleSystem[];
  32601. }
  32602. }
  32603. declare module BABYLON {
  32604. /**
  32605. * Interface used to define ActionEvent
  32606. */
  32607. export interface IActionEvent {
  32608. /** The mesh or sprite that triggered the action */
  32609. source: any;
  32610. /** The X mouse cursor position at the time of the event */
  32611. pointerX: number;
  32612. /** The Y mouse cursor position at the time of the event */
  32613. pointerY: number;
  32614. /** The mesh that is currently pointed at (can be null) */
  32615. meshUnderPointer: Nullable<AbstractMesh>;
  32616. /** the original (browser) event that triggered the ActionEvent */
  32617. sourceEvent?: any;
  32618. /** additional data for the event */
  32619. additionalData?: any;
  32620. }
  32621. /**
  32622. * ActionEvent is the event being sent when an action is triggered.
  32623. */
  32624. export class ActionEvent implements IActionEvent {
  32625. /** The mesh or sprite that triggered the action */
  32626. source: any;
  32627. /** The X mouse cursor position at the time of the event */
  32628. pointerX: number;
  32629. /** The Y mouse cursor position at the time of the event */
  32630. pointerY: number;
  32631. /** The mesh that is currently pointed at (can be null) */
  32632. meshUnderPointer: Nullable<AbstractMesh>;
  32633. /** the original (browser) event that triggered the ActionEvent */
  32634. sourceEvent?: any;
  32635. /** additional data for the event */
  32636. additionalData?: any;
  32637. /**
  32638. * Creates a new ActionEvent
  32639. * @param source The mesh or sprite that triggered the action
  32640. * @param pointerX The X mouse cursor position at the time of the event
  32641. * @param pointerY The Y mouse cursor position at the time of the event
  32642. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32643. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32644. * @param additionalData additional data for the event
  32645. */
  32646. constructor(
  32647. /** The mesh or sprite that triggered the action */
  32648. source: any,
  32649. /** The X mouse cursor position at the time of the event */
  32650. pointerX: number,
  32651. /** The Y mouse cursor position at the time of the event */
  32652. pointerY: number,
  32653. /** The mesh that is currently pointed at (can be null) */
  32654. meshUnderPointer: Nullable<AbstractMesh>,
  32655. /** the original (browser) event that triggered the ActionEvent */
  32656. sourceEvent?: any,
  32657. /** additional data for the event */
  32658. additionalData?: any);
  32659. /**
  32660. * Helper function to auto-create an ActionEvent from a source mesh.
  32661. * @param source The source mesh that triggered the event
  32662. * @param evt The original (browser) event
  32663. * @param additionalData additional data for the event
  32664. * @returns the new ActionEvent
  32665. */
  32666. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32667. /**
  32668. * Helper function to auto-create an ActionEvent from a source sprite
  32669. * @param source The source sprite that triggered the event
  32670. * @param scene Scene associated with the sprite
  32671. * @param evt The original (browser) event
  32672. * @param additionalData additional data for the event
  32673. * @returns the new ActionEvent
  32674. */
  32675. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32676. /**
  32677. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32678. * @param scene the scene where the event occurred
  32679. * @param evt The original (browser) event
  32680. * @returns the new ActionEvent
  32681. */
  32682. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32683. /**
  32684. * Helper function to auto-create an ActionEvent from a primitive
  32685. * @param prim defines the target primitive
  32686. * @param pointerPos defines the pointer position
  32687. * @param evt The original (browser) event
  32688. * @param additionalData additional data for the event
  32689. * @returns the new ActionEvent
  32690. */
  32691. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32692. }
  32693. }
  32694. declare module BABYLON {
  32695. /**
  32696. * Abstract class used to decouple action Manager from scene and meshes.
  32697. * Do not instantiate.
  32698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32699. */
  32700. export abstract class AbstractActionManager implements IDisposable {
  32701. /** Gets the list of active triggers */
  32702. static Triggers: {
  32703. [key: string]: number;
  32704. };
  32705. /** Gets the cursor to use when hovering items */
  32706. hoverCursor: string;
  32707. /** Gets the list of actions */
  32708. actions: IAction[];
  32709. /**
  32710. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32711. */
  32712. isRecursive: boolean;
  32713. /**
  32714. * Releases all associated resources
  32715. */
  32716. abstract dispose(): void;
  32717. /**
  32718. * Does this action manager has pointer triggers
  32719. */
  32720. abstract get hasPointerTriggers(): boolean;
  32721. /**
  32722. * Does this action manager has pick triggers
  32723. */
  32724. abstract get hasPickTriggers(): boolean;
  32725. /**
  32726. * Process a specific trigger
  32727. * @param trigger defines the trigger to process
  32728. * @param evt defines the event details to be processed
  32729. */
  32730. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32731. /**
  32732. * Does this action manager handles actions of any of the given triggers
  32733. * @param triggers defines the triggers to be tested
  32734. * @return a boolean indicating whether one (or more) of the triggers is handled
  32735. */
  32736. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32737. /**
  32738. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32739. * speed.
  32740. * @param triggerA defines the trigger to be tested
  32741. * @param triggerB defines the trigger to be tested
  32742. * @return a boolean indicating whether one (or more) of the triggers is handled
  32743. */
  32744. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32745. /**
  32746. * Does this action manager handles actions of a given trigger
  32747. * @param trigger defines the trigger to be tested
  32748. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32749. * @return whether the trigger is handled
  32750. */
  32751. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32752. /**
  32753. * Serialize this manager to a JSON object
  32754. * @param name defines the property name to store this manager
  32755. * @returns a JSON representation of this manager
  32756. */
  32757. abstract serialize(name: string): any;
  32758. /**
  32759. * Registers an action to this action manager
  32760. * @param action defines the action to be registered
  32761. * @return the action amended (prepared) after registration
  32762. */
  32763. abstract registerAction(action: IAction): Nullable<IAction>;
  32764. /**
  32765. * Unregisters an action to this action manager
  32766. * @param action defines the action to be unregistered
  32767. * @return a boolean indicating whether the action has been unregistered
  32768. */
  32769. abstract unregisterAction(action: IAction): Boolean;
  32770. /**
  32771. * Does exist one action manager with at least one trigger
  32772. **/
  32773. static get HasTriggers(): boolean;
  32774. /**
  32775. * Does exist one action manager with at least one pick trigger
  32776. **/
  32777. static get HasPickTriggers(): boolean;
  32778. /**
  32779. * Does exist one action manager that handles actions of a given trigger
  32780. * @param trigger defines the trigger to be tested
  32781. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32782. **/
  32783. static HasSpecificTrigger(trigger: number): boolean;
  32784. }
  32785. }
  32786. declare module BABYLON {
  32787. /**
  32788. * Defines how a node can be built from a string name.
  32789. */
  32790. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32791. /**
  32792. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32793. */
  32794. export class Node implements IBehaviorAware<Node> {
  32795. /** @hidden */
  32796. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32797. private static _NodeConstructors;
  32798. /**
  32799. * Add a new node constructor
  32800. * @param type defines the type name of the node to construct
  32801. * @param constructorFunc defines the constructor function
  32802. */
  32803. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32804. /**
  32805. * Returns a node constructor based on type name
  32806. * @param type defines the type name
  32807. * @param name defines the new node name
  32808. * @param scene defines the hosting scene
  32809. * @param options defines optional options to transmit to constructors
  32810. * @returns the new constructor or null
  32811. */
  32812. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32813. /**
  32814. * Gets or sets the name of the node
  32815. */
  32816. name: string;
  32817. /**
  32818. * Gets or sets the id of the node
  32819. */
  32820. id: string;
  32821. /**
  32822. * Gets or sets the unique id of the node
  32823. */
  32824. uniqueId: number;
  32825. /**
  32826. * Gets or sets a string used to store user defined state for the node
  32827. */
  32828. state: string;
  32829. /**
  32830. * Gets or sets an object used to store user defined information for the node
  32831. */
  32832. metadata: any;
  32833. /**
  32834. * For internal use only. Please do not use.
  32835. */
  32836. reservedDataStore: any;
  32837. /**
  32838. * List of inspectable custom properties (used by the Inspector)
  32839. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32840. */
  32841. inspectableCustomProperties: IInspectable[];
  32842. private _doNotSerialize;
  32843. /**
  32844. * Gets or sets a boolean used to define if the node must be serialized
  32845. */
  32846. get doNotSerialize(): boolean;
  32847. set doNotSerialize(value: boolean);
  32848. /** @hidden */
  32849. _isDisposed: boolean;
  32850. /**
  32851. * Gets a list of Animations associated with the node
  32852. */
  32853. animations: Animation[];
  32854. protected _ranges: {
  32855. [name: string]: Nullable<AnimationRange>;
  32856. };
  32857. /**
  32858. * Callback raised when the node is ready to be used
  32859. */
  32860. onReady: Nullable<(node: Node) => void>;
  32861. private _isEnabled;
  32862. private _isParentEnabled;
  32863. private _isReady;
  32864. /** @hidden */
  32865. _currentRenderId: number;
  32866. private _parentUpdateId;
  32867. /** @hidden */
  32868. _childUpdateId: number;
  32869. /** @hidden */
  32870. _waitingParentId: Nullable<string>;
  32871. /** @hidden */
  32872. _scene: Scene;
  32873. /** @hidden */
  32874. _cache: any;
  32875. private _parentNode;
  32876. private _children;
  32877. /** @hidden */
  32878. _worldMatrix: Matrix;
  32879. /** @hidden */
  32880. _worldMatrixDeterminant: number;
  32881. /** @hidden */
  32882. _worldMatrixDeterminantIsDirty: boolean;
  32883. /** @hidden */
  32884. private _sceneRootNodesIndex;
  32885. /**
  32886. * Gets a boolean indicating if the node has been disposed
  32887. * @returns true if the node was disposed
  32888. */
  32889. isDisposed(): boolean;
  32890. /**
  32891. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32892. * @see https://doc.babylonjs.com/how_to/parenting
  32893. */
  32894. set parent(parent: Nullable<Node>);
  32895. get parent(): Nullable<Node>;
  32896. /** @hidden */
  32897. _addToSceneRootNodes(): void;
  32898. /** @hidden */
  32899. _removeFromSceneRootNodes(): void;
  32900. private _animationPropertiesOverride;
  32901. /**
  32902. * Gets or sets the animation properties override
  32903. */
  32904. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32905. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32906. /**
  32907. * Gets a string idenfifying the name of the class
  32908. * @returns "Node" string
  32909. */
  32910. getClassName(): string;
  32911. /** @hidden */
  32912. readonly _isNode: boolean;
  32913. /**
  32914. * An event triggered when the mesh is disposed
  32915. */
  32916. onDisposeObservable: Observable<Node>;
  32917. private _onDisposeObserver;
  32918. /**
  32919. * Sets a callback that will be raised when the node will be disposed
  32920. */
  32921. set onDispose(callback: () => void);
  32922. /**
  32923. * Creates a new Node
  32924. * @param name the name and id to be given to this node
  32925. * @param scene the scene this node will be added to
  32926. */
  32927. constructor(name: string, scene?: Nullable<Scene>);
  32928. /**
  32929. * Gets the scene of the node
  32930. * @returns a scene
  32931. */
  32932. getScene(): Scene;
  32933. /**
  32934. * Gets the engine of the node
  32935. * @returns a Engine
  32936. */
  32937. getEngine(): Engine;
  32938. private _behaviors;
  32939. /**
  32940. * Attach a behavior to the node
  32941. * @see https://doc.babylonjs.com/features/behaviour
  32942. * @param behavior defines the behavior to attach
  32943. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32944. * @returns the current Node
  32945. */
  32946. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32947. /**
  32948. * Remove an attached behavior
  32949. * @see https://doc.babylonjs.com/features/behaviour
  32950. * @param behavior defines the behavior to attach
  32951. * @returns the current Node
  32952. */
  32953. removeBehavior(behavior: Behavior<Node>): Node;
  32954. /**
  32955. * Gets the list of attached behaviors
  32956. * @see https://doc.babylonjs.com/features/behaviour
  32957. */
  32958. get behaviors(): Behavior<Node>[];
  32959. /**
  32960. * Gets an attached behavior by name
  32961. * @param name defines the name of the behavior to look for
  32962. * @see https://doc.babylonjs.com/features/behaviour
  32963. * @returns null if behavior was not found else the requested behavior
  32964. */
  32965. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32966. /**
  32967. * Returns the latest update of the World matrix
  32968. * @returns a Matrix
  32969. */
  32970. getWorldMatrix(): Matrix;
  32971. /** @hidden */
  32972. _getWorldMatrixDeterminant(): number;
  32973. /**
  32974. * Returns directly the latest state of the mesh World matrix.
  32975. * A Matrix is returned.
  32976. */
  32977. get worldMatrixFromCache(): Matrix;
  32978. /** @hidden */
  32979. _initCache(): void;
  32980. /** @hidden */
  32981. updateCache(force?: boolean): void;
  32982. /** @hidden */
  32983. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32984. /** @hidden */
  32985. _updateCache(ignoreParentClass?: boolean): void;
  32986. /** @hidden */
  32987. _isSynchronized(): boolean;
  32988. /** @hidden */
  32989. _markSyncedWithParent(): void;
  32990. /** @hidden */
  32991. isSynchronizedWithParent(): boolean;
  32992. /** @hidden */
  32993. isSynchronized(): boolean;
  32994. /**
  32995. * Is this node ready to be used/rendered
  32996. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32997. * @return true if the node is ready
  32998. */
  32999. isReady(completeCheck?: boolean): boolean;
  33000. /**
  33001. * Is this node enabled?
  33002. * 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
  33003. * @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
  33004. * @return whether this node (and its parent) is enabled
  33005. */
  33006. isEnabled(checkAncestors?: boolean): boolean;
  33007. /** @hidden */
  33008. protected _syncParentEnabledState(): void;
  33009. /**
  33010. * Set the enabled state of this node
  33011. * @param value defines the new enabled state
  33012. */
  33013. setEnabled(value: boolean): void;
  33014. /**
  33015. * Is this node a descendant of the given node?
  33016. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33017. * @param ancestor defines the parent node to inspect
  33018. * @returns a boolean indicating if this node is a descendant of the given node
  33019. */
  33020. isDescendantOf(ancestor: Node): boolean;
  33021. /** @hidden */
  33022. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33023. /**
  33024. * Will return all nodes that have this node as ascendant
  33025. * @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
  33026. * @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
  33027. * @return all children nodes of all types
  33028. */
  33029. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33030. /**
  33031. * Get all child-meshes of this node
  33032. * @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)
  33033. * @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
  33034. * @returns an array of AbstractMesh
  33035. */
  33036. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33037. /**
  33038. * Get all direct children of this node
  33039. * @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
  33040. * @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)
  33041. * @returns an array of Node
  33042. */
  33043. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33044. /** @hidden */
  33045. _setReady(state: boolean): void;
  33046. /**
  33047. * Get an animation by name
  33048. * @param name defines the name of the animation to look for
  33049. * @returns null if not found else the requested animation
  33050. */
  33051. getAnimationByName(name: string): Nullable<Animation>;
  33052. /**
  33053. * Creates an animation range for this node
  33054. * @param name defines the name of the range
  33055. * @param from defines the starting key
  33056. * @param to defines the end key
  33057. */
  33058. createAnimationRange(name: string, from: number, to: number): void;
  33059. /**
  33060. * Delete a specific animation range
  33061. * @param name defines the name of the range to delete
  33062. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33063. */
  33064. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33065. /**
  33066. * Get an animation range by name
  33067. * @param name defines the name of the animation range to look for
  33068. * @returns null if not found else the requested animation range
  33069. */
  33070. getAnimationRange(name: string): Nullable<AnimationRange>;
  33071. /**
  33072. * Gets the list of all animation ranges defined on this node
  33073. * @returns an array
  33074. */
  33075. getAnimationRanges(): Nullable<AnimationRange>[];
  33076. /**
  33077. * Will start the animation sequence
  33078. * @param name defines the range frames for animation sequence
  33079. * @param loop defines if the animation should loop (false by default)
  33080. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33081. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33082. * @returns the object created for this animation. If range does not exist, it will return null
  33083. */
  33084. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33085. /**
  33086. * Serialize animation ranges into a JSON compatible object
  33087. * @returns serialization object
  33088. */
  33089. serializeAnimationRanges(): any;
  33090. /**
  33091. * Computes the world matrix of the node
  33092. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33093. * @returns the world matrix
  33094. */
  33095. computeWorldMatrix(force?: boolean): Matrix;
  33096. /**
  33097. * Releases resources associated with this node.
  33098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33100. */
  33101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33102. /**
  33103. * Parse animation range data from a serialization object and store them into a given node
  33104. * @param node defines where to store the animation ranges
  33105. * @param parsedNode defines the serialization object to read data from
  33106. * @param scene defines the hosting scene
  33107. */
  33108. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33109. /**
  33110. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33111. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33112. * @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
  33113. * @returns the new bounding vectors
  33114. */
  33115. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33116. min: Vector3;
  33117. max: Vector3;
  33118. };
  33119. }
  33120. }
  33121. declare module BABYLON {
  33122. /**
  33123. * @hidden
  33124. */
  33125. export class _IAnimationState {
  33126. key: number;
  33127. repeatCount: number;
  33128. workValue?: any;
  33129. loopMode?: number;
  33130. offsetValue?: any;
  33131. highLimitValue?: any;
  33132. }
  33133. /**
  33134. * Class used to store any kind of animation
  33135. */
  33136. export class Animation {
  33137. /**Name of the animation */
  33138. name: string;
  33139. /**Property to animate */
  33140. targetProperty: string;
  33141. /**The frames per second of the animation */
  33142. framePerSecond: number;
  33143. /**The data type of the animation */
  33144. dataType: number;
  33145. /**The loop mode of the animation */
  33146. loopMode?: number | undefined;
  33147. /**Specifies if blending should be enabled */
  33148. enableBlending?: boolean | undefined;
  33149. /**
  33150. * Use matrix interpolation instead of using direct key value when animating matrices
  33151. */
  33152. static AllowMatricesInterpolation: boolean;
  33153. /**
  33154. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33155. */
  33156. static AllowMatrixDecomposeForInterpolation: boolean;
  33157. /** Define the Url to load snippets */
  33158. static SnippetUrl: string;
  33159. /** Snippet ID if the animation was created from the snippet server */
  33160. snippetId: string;
  33161. /**
  33162. * Stores the key frames of the animation
  33163. */
  33164. private _keys;
  33165. /**
  33166. * Stores the easing function of the animation
  33167. */
  33168. private _easingFunction;
  33169. /**
  33170. * @hidden Internal use only
  33171. */
  33172. _runtimeAnimations: RuntimeAnimation[];
  33173. /**
  33174. * The set of event that will be linked to this animation
  33175. */
  33176. private _events;
  33177. /**
  33178. * Stores an array of target property paths
  33179. */
  33180. targetPropertyPath: string[];
  33181. /**
  33182. * Stores the blending speed of the animation
  33183. */
  33184. blendingSpeed: number;
  33185. /**
  33186. * Stores the animation ranges for the animation
  33187. */
  33188. private _ranges;
  33189. /**
  33190. * @hidden Internal use
  33191. */
  33192. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33193. /**
  33194. * Sets up an animation
  33195. * @param property The property to animate
  33196. * @param animationType The animation type to apply
  33197. * @param framePerSecond The frames per second of the animation
  33198. * @param easingFunction The easing function used in the animation
  33199. * @returns The created animation
  33200. */
  33201. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33202. /**
  33203. * Create and start an animation on a node
  33204. * @param name defines the name of the global animation that will be run on all nodes
  33205. * @param node defines the root node where the animation will take place
  33206. * @param targetProperty defines property to animate
  33207. * @param framePerSecond defines the number of frame per second yo use
  33208. * @param totalFrame defines the number of frames in total
  33209. * @param from defines the initial value
  33210. * @param to defines the final value
  33211. * @param loopMode defines which loop mode you want to use (off by default)
  33212. * @param easingFunction defines the easing function to use (linear by default)
  33213. * @param onAnimationEnd defines the callback to call when animation end
  33214. * @returns the animatable created for this animation
  33215. */
  33216. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33217. /**
  33218. * Create and start an animation on a node and its descendants
  33219. * @param name defines the name of the global animation that will be run on all nodes
  33220. * @param node defines the root node where the animation will take place
  33221. * @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
  33222. * @param targetProperty defines property to animate
  33223. * @param framePerSecond defines the number of frame per second to use
  33224. * @param totalFrame defines the number of frames in total
  33225. * @param from defines the initial value
  33226. * @param to defines the final value
  33227. * @param loopMode defines which loop mode you want to use (off by default)
  33228. * @param easingFunction defines the easing function to use (linear by default)
  33229. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33230. * @returns the list of animatables created for all nodes
  33231. * @example https://www.babylonjs-playground.com/#MH0VLI
  33232. */
  33233. 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[]>;
  33234. /**
  33235. * Creates a new animation, merges it with the existing animations and starts it
  33236. * @param name Name of the animation
  33237. * @param node Node which contains the scene that begins the animations
  33238. * @param targetProperty Specifies which property to animate
  33239. * @param framePerSecond The frames per second of the animation
  33240. * @param totalFrame The total number of frames
  33241. * @param from The frame at the beginning of the animation
  33242. * @param to The frame at the end of the animation
  33243. * @param loopMode Specifies the loop mode of the animation
  33244. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33245. * @param onAnimationEnd Callback to run once the animation is complete
  33246. * @returns Nullable animation
  33247. */
  33248. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33249. /**
  33250. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33251. * @param sourceAnimation defines the Animation containing keyframes to convert
  33252. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33253. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33254. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33255. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33256. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33257. */
  33258. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33259. /**
  33260. * Transition property of an host to the target Value
  33261. * @param property The property to transition
  33262. * @param targetValue The target Value of the property
  33263. * @param host The object where the property to animate belongs
  33264. * @param scene Scene used to run the animation
  33265. * @param frameRate Framerate (in frame/s) to use
  33266. * @param transition The transition type we want to use
  33267. * @param duration The duration of the animation, in milliseconds
  33268. * @param onAnimationEnd Callback trigger at the end of the animation
  33269. * @returns Nullable animation
  33270. */
  33271. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33272. /**
  33273. * Return the array of runtime animations currently using this animation
  33274. */
  33275. get runtimeAnimations(): RuntimeAnimation[];
  33276. /**
  33277. * Specifies if any of the runtime animations are currently running
  33278. */
  33279. get hasRunningRuntimeAnimations(): boolean;
  33280. /**
  33281. * Initializes the animation
  33282. * @param name Name of the animation
  33283. * @param targetProperty Property to animate
  33284. * @param framePerSecond The frames per second of the animation
  33285. * @param dataType The data type of the animation
  33286. * @param loopMode The loop mode of the animation
  33287. * @param enableBlending Specifies if blending should be enabled
  33288. */
  33289. constructor(
  33290. /**Name of the animation */
  33291. name: string,
  33292. /**Property to animate */
  33293. targetProperty: string,
  33294. /**The frames per second of the animation */
  33295. framePerSecond: number,
  33296. /**The data type of the animation */
  33297. dataType: number,
  33298. /**The loop mode of the animation */
  33299. loopMode?: number | undefined,
  33300. /**Specifies if blending should be enabled */
  33301. enableBlending?: boolean | undefined);
  33302. /**
  33303. * Converts the animation to a string
  33304. * @param fullDetails support for multiple levels of logging within scene loading
  33305. * @returns String form of the animation
  33306. */
  33307. toString(fullDetails?: boolean): string;
  33308. /**
  33309. * Add an event to this animation
  33310. * @param event Event to add
  33311. */
  33312. addEvent(event: AnimationEvent): void;
  33313. /**
  33314. * Remove all events found at the given frame
  33315. * @param frame The frame to remove events from
  33316. */
  33317. removeEvents(frame: number): void;
  33318. /**
  33319. * Retrieves all the events from the animation
  33320. * @returns Events from the animation
  33321. */
  33322. getEvents(): AnimationEvent[];
  33323. /**
  33324. * Creates an animation range
  33325. * @param name Name of the animation range
  33326. * @param from Starting frame of the animation range
  33327. * @param to Ending frame of the animation
  33328. */
  33329. createRange(name: string, from: number, to: number): void;
  33330. /**
  33331. * Deletes an animation range by name
  33332. * @param name Name of the animation range to delete
  33333. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33334. */
  33335. deleteRange(name: string, deleteFrames?: boolean): void;
  33336. /**
  33337. * Gets the animation range by name, or null if not defined
  33338. * @param name Name of the animation range
  33339. * @returns Nullable animation range
  33340. */
  33341. getRange(name: string): Nullable<AnimationRange>;
  33342. /**
  33343. * Gets the key frames from the animation
  33344. * @returns The key frames of the animation
  33345. */
  33346. getKeys(): Array<IAnimationKey>;
  33347. /**
  33348. * Gets the highest frame rate of the animation
  33349. * @returns Highest frame rate of the animation
  33350. */
  33351. getHighestFrame(): number;
  33352. /**
  33353. * Gets the easing function of the animation
  33354. * @returns Easing function of the animation
  33355. */
  33356. getEasingFunction(): IEasingFunction;
  33357. /**
  33358. * Sets the easing function of the animation
  33359. * @param easingFunction A custom mathematical formula for animation
  33360. */
  33361. setEasingFunction(easingFunction: EasingFunction): void;
  33362. /**
  33363. * Interpolates a scalar linearly
  33364. * @param startValue Start value of the animation curve
  33365. * @param endValue End value of the animation curve
  33366. * @param gradient Scalar amount to interpolate
  33367. * @returns Interpolated scalar value
  33368. */
  33369. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33370. /**
  33371. * Interpolates a scalar cubically
  33372. * @param startValue Start value of the animation curve
  33373. * @param outTangent End tangent of the animation
  33374. * @param endValue End value of the animation curve
  33375. * @param inTangent Start tangent of the animation curve
  33376. * @param gradient Scalar amount to interpolate
  33377. * @returns Interpolated scalar value
  33378. */
  33379. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33380. /**
  33381. * Interpolates a quaternion using a spherical linear interpolation
  33382. * @param startValue Start value of the animation curve
  33383. * @param endValue End value of the animation curve
  33384. * @param gradient Scalar amount to interpolate
  33385. * @returns Interpolated quaternion value
  33386. */
  33387. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33388. /**
  33389. * Interpolates a quaternion cubically
  33390. * @param startValue Start value of the animation curve
  33391. * @param outTangent End tangent of the animation curve
  33392. * @param endValue End value of the animation curve
  33393. * @param inTangent Start tangent of the animation curve
  33394. * @param gradient Scalar amount to interpolate
  33395. * @returns Interpolated quaternion value
  33396. */
  33397. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33398. /**
  33399. * Interpolates a Vector3 linearl
  33400. * @param startValue Start value of the animation curve
  33401. * @param endValue End value of the animation curve
  33402. * @param gradient Scalar amount to interpolate
  33403. * @returns Interpolated scalar value
  33404. */
  33405. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33406. /**
  33407. * Interpolates a Vector3 cubically
  33408. * @param startValue Start value of the animation curve
  33409. * @param outTangent End tangent of the animation
  33410. * @param endValue End value of the animation curve
  33411. * @param inTangent Start tangent of the animation curve
  33412. * @param gradient Scalar amount to interpolate
  33413. * @returns InterpolatedVector3 value
  33414. */
  33415. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33416. /**
  33417. * Interpolates a Vector2 linearly
  33418. * @param startValue Start value of the animation curve
  33419. * @param endValue End value of the animation curve
  33420. * @param gradient Scalar amount to interpolate
  33421. * @returns Interpolated Vector2 value
  33422. */
  33423. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33424. /**
  33425. * Interpolates a Vector2 cubically
  33426. * @param startValue Start value of the animation curve
  33427. * @param outTangent End tangent of the animation
  33428. * @param endValue End value of the animation curve
  33429. * @param inTangent Start tangent of the animation curve
  33430. * @param gradient Scalar amount to interpolate
  33431. * @returns Interpolated Vector2 value
  33432. */
  33433. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33434. /**
  33435. * Interpolates a size linearly
  33436. * @param startValue Start value of the animation curve
  33437. * @param endValue End value of the animation curve
  33438. * @param gradient Scalar amount to interpolate
  33439. * @returns Interpolated Size value
  33440. */
  33441. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33442. /**
  33443. * Interpolates a Color3 linearly
  33444. * @param startValue Start value of the animation curve
  33445. * @param endValue End value of the animation curve
  33446. * @param gradient Scalar amount to interpolate
  33447. * @returns Interpolated Color3 value
  33448. */
  33449. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33450. /**
  33451. * Interpolates a Color4 linearly
  33452. * @param startValue Start value of the animation curve
  33453. * @param endValue End value of the animation curve
  33454. * @param gradient Scalar amount to interpolate
  33455. * @returns Interpolated Color3 value
  33456. */
  33457. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33458. /**
  33459. * @hidden Internal use only
  33460. */
  33461. _getKeyValue(value: any): any;
  33462. /**
  33463. * @hidden Internal use only
  33464. */
  33465. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33466. /**
  33467. * Defines the function to use to interpolate matrices
  33468. * @param startValue defines the start matrix
  33469. * @param endValue defines the end matrix
  33470. * @param gradient defines the gradient between both matrices
  33471. * @param result defines an optional target matrix where to store the interpolation
  33472. * @returns the interpolated matrix
  33473. */
  33474. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33475. /**
  33476. * Makes a copy of the animation
  33477. * @returns Cloned animation
  33478. */
  33479. clone(): Animation;
  33480. /**
  33481. * Sets the key frames of the animation
  33482. * @param values The animation key frames to set
  33483. */
  33484. setKeys(values: Array<IAnimationKey>): void;
  33485. /**
  33486. * Serializes the animation to an object
  33487. * @returns Serialized object
  33488. */
  33489. serialize(): any;
  33490. /**
  33491. * Float animation type
  33492. */
  33493. static readonly ANIMATIONTYPE_FLOAT: number;
  33494. /**
  33495. * Vector3 animation type
  33496. */
  33497. static readonly ANIMATIONTYPE_VECTOR3: number;
  33498. /**
  33499. * Quaternion animation type
  33500. */
  33501. static readonly ANIMATIONTYPE_QUATERNION: number;
  33502. /**
  33503. * Matrix animation type
  33504. */
  33505. static readonly ANIMATIONTYPE_MATRIX: number;
  33506. /**
  33507. * Color3 animation type
  33508. */
  33509. static readonly ANIMATIONTYPE_COLOR3: number;
  33510. /**
  33511. * Color3 animation type
  33512. */
  33513. static readonly ANIMATIONTYPE_COLOR4: number;
  33514. /**
  33515. * Vector2 animation type
  33516. */
  33517. static readonly ANIMATIONTYPE_VECTOR2: number;
  33518. /**
  33519. * Size animation type
  33520. */
  33521. static readonly ANIMATIONTYPE_SIZE: number;
  33522. /**
  33523. * Relative Loop Mode
  33524. */
  33525. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33526. /**
  33527. * Cycle Loop Mode
  33528. */
  33529. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33530. /**
  33531. * Constant Loop Mode
  33532. */
  33533. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33534. /** @hidden */
  33535. static _UniversalLerp(left: any, right: any, amount: number): any;
  33536. /**
  33537. * Parses an animation object and creates an animation
  33538. * @param parsedAnimation Parsed animation object
  33539. * @returns Animation object
  33540. */
  33541. static Parse(parsedAnimation: any): Animation;
  33542. /**
  33543. * Appends the serialized animations from the source animations
  33544. * @param source Source containing the animations
  33545. * @param destination Target to store the animations
  33546. */
  33547. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33548. /**
  33549. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33550. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33551. * @param url defines the url to load from
  33552. * @returns a promise that will resolve to the new animation or an array of animations
  33553. */
  33554. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33555. /**
  33556. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33557. * @param snippetId defines the snippet to load
  33558. * @returns a promise that will resolve to the new animation or a new array of animations
  33559. */
  33560. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33561. }
  33562. }
  33563. declare module BABYLON {
  33564. /**
  33565. * Interface containing an array of animations
  33566. */
  33567. export interface IAnimatable {
  33568. /**
  33569. * Array of animations
  33570. */
  33571. animations: Nullable<Array<Animation>>;
  33572. }
  33573. }
  33574. declare module BABYLON {
  33575. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33576. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33577. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33578. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33579. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33580. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33581. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33582. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33583. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33584. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33585. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33586. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33587. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33588. /**
  33589. * Decorator used to define property that can be serialized as reference to a camera
  33590. * @param sourceName defines the name of the property to decorate
  33591. */
  33592. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33593. /**
  33594. * Class used to help serialization objects
  33595. */
  33596. export class SerializationHelper {
  33597. /** @hidden */
  33598. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33599. /** @hidden */
  33600. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33601. /** @hidden */
  33602. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33603. /** @hidden */
  33604. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33605. /**
  33606. * Appends the serialized animations from the source animations
  33607. * @param source Source containing the animations
  33608. * @param destination Target to store the animations
  33609. */
  33610. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33611. /**
  33612. * Static function used to serialized a specific entity
  33613. * @param entity defines the entity to serialize
  33614. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33615. * @returns a JSON compatible object representing the serialization of the entity
  33616. */
  33617. static Serialize<T>(entity: T, serializationObject?: any): any;
  33618. /**
  33619. * Creates a new entity from a serialization data object
  33620. * @param creationFunction defines a function used to instanciated the new entity
  33621. * @param source defines the source serialization data
  33622. * @param scene defines the hosting scene
  33623. * @param rootUrl defines the root url for resources
  33624. * @returns a new entity
  33625. */
  33626. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33627. /**
  33628. * Clones an object
  33629. * @param creationFunction defines the function used to instanciate the new object
  33630. * @param source defines the source object
  33631. * @returns the cloned object
  33632. */
  33633. static Clone<T>(creationFunction: () => T, source: T): T;
  33634. /**
  33635. * Instanciates a new object based on a source one (some data will be shared between both object)
  33636. * @param creationFunction defines the function used to instanciate the new object
  33637. * @param source defines the source object
  33638. * @returns the new object
  33639. */
  33640. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33641. }
  33642. }
  33643. declare module BABYLON {
  33644. /**
  33645. * Base class of all the textures in babylon.
  33646. * It groups all the common properties the materials, post process, lights... might need
  33647. * in order to make a correct use of the texture.
  33648. */
  33649. export class BaseTexture implements IAnimatable {
  33650. /**
  33651. * Default anisotropic filtering level for the application.
  33652. * It is set to 4 as a good tradeoff between perf and quality.
  33653. */
  33654. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33655. /**
  33656. * Gets or sets the unique id of the texture
  33657. */
  33658. uniqueId: number;
  33659. /**
  33660. * Define the name of the texture.
  33661. */
  33662. name: string;
  33663. /**
  33664. * Gets or sets an object used to store user defined information.
  33665. */
  33666. metadata: any;
  33667. /**
  33668. * For internal use only. Please do not use.
  33669. */
  33670. reservedDataStore: any;
  33671. private _hasAlpha;
  33672. /**
  33673. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33674. */
  33675. set hasAlpha(value: boolean);
  33676. get hasAlpha(): boolean;
  33677. /**
  33678. * Defines if the alpha value should be determined via the rgb values.
  33679. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33680. */
  33681. getAlphaFromRGB: boolean;
  33682. /**
  33683. * Intensity or strength of the texture.
  33684. * It is commonly used by materials to fine tune the intensity of the texture
  33685. */
  33686. level: number;
  33687. /**
  33688. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33689. * This is part of the texture as textures usually maps to one uv set.
  33690. */
  33691. coordinatesIndex: number;
  33692. private _coordinatesMode;
  33693. /**
  33694. * How a texture is mapped.
  33695. *
  33696. * | Value | Type | Description |
  33697. * | ----- | ----------------------------------- | ----------- |
  33698. * | 0 | EXPLICIT_MODE | |
  33699. * | 1 | SPHERICAL_MODE | |
  33700. * | 2 | PLANAR_MODE | |
  33701. * | 3 | CUBIC_MODE | |
  33702. * | 4 | PROJECTION_MODE | |
  33703. * | 5 | SKYBOX_MODE | |
  33704. * | 6 | INVCUBIC_MODE | |
  33705. * | 7 | EQUIRECTANGULAR_MODE | |
  33706. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33707. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33708. */
  33709. set coordinatesMode(value: number);
  33710. get coordinatesMode(): number;
  33711. /**
  33712. * | Value | Type | Description |
  33713. * | ----- | ------------------ | ----------- |
  33714. * | 0 | CLAMP_ADDRESSMODE | |
  33715. * | 1 | WRAP_ADDRESSMODE | |
  33716. * | 2 | MIRROR_ADDRESSMODE | |
  33717. */
  33718. wrapU: number;
  33719. /**
  33720. * | Value | Type | Description |
  33721. * | ----- | ------------------ | ----------- |
  33722. * | 0 | CLAMP_ADDRESSMODE | |
  33723. * | 1 | WRAP_ADDRESSMODE | |
  33724. * | 2 | MIRROR_ADDRESSMODE | |
  33725. */
  33726. wrapV: number;
  33727. /**
  33728. * | Value | Type | Description |
  33729. * | ----- | ------------------ | ----------- |
  33730. * | 0 | CLAMP_ADDRESSMODE | |
  33731. * | 1 | WRAP_ADDRESSMODE | |
  33732. * | 2 | MIRROR_ADDRESSMODE | |
  33733. */
  33734. wrapR: number;
  33735. /**
  33736. * With compliant hardware and browser (supporting anisotropic filtering)
  33737. * this defines the level of anisotropic filtering in the texture.
  33738. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33739. */
  33740. anisotropicFilteringLevel: number;
  33741. /**
  33742. * Define if the texture is a cube texture or if false a 2d texture.
  33743. */
  33744. get isCube(): boolean;
  33745. set isCube(value: boolean);
  33746. /**
  33747. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33748. */
  33749. get is3D(): boolean;
  33750. set is3D(value: boolean);
  33751. /**
  33752. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33753. */
  33754. get is2DArray(): boolean;
  33755. set is2DArray(value: boolean);
  33756. /**
  33757. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33758. * HDR texture are usually stored in linear space.
  33759. * This only impacts the PBR and Background materials
  33760. */
  33761. gammaSpace: boolean;
  33762. /**
  33763. * Gets or sets whether or not the texture contains RGBD data.
  33764. */
  33765. get isRGBD(): boolean;
  33766. set isRGBD(value: boolean);
  33767. /**
  33768. * Is Z inverted in the texture (useful in a cube texture).
  33769. */
  33770. invertZ: boolean;
  33771. /**
  33772. * Are mip maps generated for this texture or not.
  33773. */
  33774. get noMipmap(): boolean;
  33775. /**
  33776. * @hidden
  33777. */
  33778. lodLevelInAlpha: boolean;
  33779. /**
  33780. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33781. */
  33782. get lodGenerationOffset(): number;
  33783. set lodGenerationOffset(value: number);
  33784. /**
  33785. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33786. */
  33787. get lodGenerationScale(): number;
  33788. set lodGenerationScale(value: number);
  33789. /**
  33790. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33791. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33792. * average roughness values.
  33793. */
  33794. get linearSpecularLOD(): boolean;
  33795. set linearSpecularLOD(value: boolean);
  33796. /**
  33797. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33798. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33799. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33800. */
  33801. get irradianceTexture(): Nullable<BaseTexture>;
  33802. set irradianceTexture(value: Nullable<BaseTexture>);
  33803. /**
  33804. * Define if the texture is a render target.
  33805. */
  33806. isRenderTarget: boolean;
  33807. /**
  33808. * Define the unique id of the texture in the scene.
  33809. */
  33810. get uid(): string;
  33811. /** @hidden */
  33812. _prefiltered: boolean;
  33813. /**
  33814. * Return a string representation of the texture.
  33815. * @returns the texture as a string
  33816. */
  33817. toString(): string;
  33818. /**
  33819. * Get the class name of the texture.
  33820. * @returns "BaseTexture"
  33821. */
  33822. getClassName(): string;
  33823. /**
  33824. * Define the list of animation attached to the texture.
  33825. */
  33826. animations: Animation[];
  33827. /**
  33828. * An event triggered when the texture is disposed.
  33829. */
  33830. onDisposeObservable: Observable<BaseTexture>;
  33831. private _onDisposeObserver;
  33832. /**
  33833. * Callback triggered when the texture has been disposed.
  33834. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33835. */
  33836. set onDispose(callback: () => void);
  33837. /**
  33838. * Define the current state of the loading sequence when in delayed load mode.
  33839. */
  33840. delayLoadState: number;
  33841. private _scene;
  33842. private _engine;
  33843. /** @hidden */
  33844. _texture: Nullable<InternalTexture>;
  33845. private _uid;
  33846. /**
  33847. * Define if the texture is preventinga material to render or not.
  33848. * If not and the texture is not ready, the engine will use a default black texture instead.
  33849. */
  33850. get isBlocking(): boolean;
  33851. /**
  33852. * Instantiates a new BaseTexture.
  33853. * Base class of all the textures in babylon.
  33854. * It groups all the common properties the materials, post process, lights... might need
  33855. * in order to make a correct use of the texture.
  33856. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33857. */
  33858. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33859. /**
  33860. * Get the scene the texture belongs to.
  33861. * @returns the scene or null if undefined
  33862. */
  33863. getScene(): Nullable<Scene>;
  33864. /** @hidden */
  33865. protected _getEngine(): Nullable<ThinEngine>;
  33866. /**
  33867. * Get the texture transform matrix used to offset tile the texture for istance.
  33868. * @returns the transformation matrix
  33869. */
  33870. getTextureMatrix(): Matrix;
  33871. /**
  33872. * Get the texture reflection matrix used to rotate/transform the reflection.
  33873. * @returns the reflection matrix
  33874. */
  33875. getReflectionTextureMatrix(): Matrix;
  33876. /**
  33877. * Get the underlying lower level texture from Babylon.
  33878. * @returns the insternal texture
  33879. */
  33880. getInternalTexture(): Nullable<InternalTexture>;
  33881. /**
  33882. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33883. * @returns true if ready or not blocking
  33884. */
  33885. isReadyOrNotBlocking(): boolean;
  33886. /**
  33887. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33888. * @returns true if fully ready
  33889. */
  33890. isReady(): boolean;
  33891. private _cachedSize;
  33892. /**
  33893. * Get the size of the texture.
  33894. * @returns the texture size.
  33895. */
  33896. getSize(): ISize;
  33897. /**
  33898. * Get the base size of the texture.
  33899. * It can be different from the size if the texture has been resized for POT for instance
  33900. * @returns the base size
  33901. */
  33902. getBaseSize(): ISize;
  33903. /**
  33904. * Update the sampling mode of the texture.
  33905. * Default is Trilinear mode.
  33906. *
  33907. * | Value | Type | Description |
  33908. * | ----- | ------------------ | ----------- |
  33909. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33910. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33911. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33912. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33913. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33914. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33915. * | 7 | NEAREST_LINEAR | |
  33916. * | 8 | NEAREST_NEAREST | |
  33917. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33918. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33919. * | 11 | LINEAR_LINEAR | |
  33920. * | 12 | LINEAR_NEAREST | |
  33921. *
  33922. * > _mag_: magnification filter (close to the viewer)
  33923. * > _min_: minification filter (far from the viewer)
  33924. * > _mip_: filter used between mip map levels
  33925. *@param samplingMode Define the new sampling mode of the texture
  33926. */
  33927. updateSamplingMode(samplingMode: number): void;
  33928. /**
  33929. * Scales the texture if is `canRescale()`
  33930. * @param ratio the resize factor we want to use to rescale
  33931. */
  33932. scale(ratio: number): void;
  33933. /**
  33934. * Get if the texture can rescale.
  33935. */
  33936. get canRescale(): boolean;
  33937. /** @hidden */
  33938. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33939. /** @hidden */
  33940. _rebuild(): void;
  33941. /**
  33942. * Triggers the load sequence in delayed load mode.
  33943. */
  33944. delayLoad(): void;
  33945. /**
  33946. * Clones the texture.
  33947. * @returns the cloned texture
  33948. */
  33949. clone(): Nullable<BaseTexture>;
  33950. /**
  33951. * Get the texture underlying type (INT, FLOAT...)
  33952. */
  33953. get textureType(): number;
  33954. /**
  33955. * Get the texture underlying format (RGB, RGBA...)
  33956. */
  33957. get textureFormat(): number;
  33958. /**
  33959. * Indicates that textures need to be re-calculated for all materials
  33960. */
  33961. protected _markAllSubMeshesAsTexturesDirty(): void;
  33962. /**
  33963. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33964. * This will returns an RGBA array buffer containing either in values (0-255) or
  33965. * float values (0-1) depending of the underlying buffer type.
  33966. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33967. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33968. * @param buffer defines a user defined buffer to fill with data (can be null)
  33969. * @returns The Array buffer containing the pixels data.
  33970. */
  33971. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33972. /**
  33973. * Release and destroy the underlying lower level texture aka internalTexture.
  33974. */
  33975. releaseInternalTexture(): void;
  33976. /** @hidden */
  33977. get _lodTextureHigh(): Nullable<BaseTexture>;
  33978. /** @hidden */
  33979. get _lodTextureMid(): Nullable<BaseTexture>;
  33980. /** @hidden */
  33981. get _lodTextureLow(): Nullable<BaseTexture>;
  33982. /**
  33983. * Dispose the texture and release its associated resources.
  33984. */
  33985. dispose(): void;
  33986. /**
  33987. * Serialize the texture into a JSON representation that can be parsed later on.
  33988. * @returns the JSON representation of the texture
  33989. */
  33990. serialize(): any;
  33991. /**
  33992. * Helper function to be called back once a list of texture contains only ready textures.
  33993. * @param textures Define the list of textures to wait for
  33994. * @param callback Define the callback triggered once the entire list will be ready
  33995. */
  33996. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33997. private static _isScene;
  33998. }
  33999. }
  34000. declare module BABYLON {
  34001. /**
  34002. * Options to be used when creating an effect.
  34003. */
  34004. export interface IEffectCreationOptions {
  34005. /**
  34006. * Atrributes that will be used in the shader.
  34007. */
  34008. attributes: string[];
  34009. /**
  34010. * Uniform varible names that will be set in the shader.
  34011. */
  34012. uniformsNames: string[];
  34013. /**
  34014. * Uniform buffer variable names that will be set in the shader.
  34015. */
  34016. uniformBuffersNames: string[];
  34017. /**
  34018. * Sampler texture variable names that will be set in the shader.
  34019. */
  34020. samplers: string[];
  34021. /**
  34022. * Define statements that will be set in the shader.
  34023. */
  34024. defines: any;
  34025. /**
  34026. * Possible fallbacks for this effect to improve performance when needed.
  34027. */
  34028. fallbacks: Nullable<IEffectFallbacks>;
  34029. /**
  34030. * Callback that will be called when the shader is compiled.
  34031. */
  34032. onCompiled: Nullable<(effect: Effect) => void>;
  34033. /**
  34034. * Callback that will be called if an error occurs during shader compilation.
  34035. */
  34036. onError: Nullable<(effect: Effect, errors: string) => void>;
  34037. /**
  34038. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34039. */
  34040. indexParameters?: any;
  34041. /**
  34042. * Max number of lights that can be used in the shader.
  34043. */
  34044. maxSimultaneousLights?: number;
  34045. /**
  34046. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34047. */
  34048. transformFeedbackVaryings?: Nullable<string[]>;
  34049. /**
  34050. * 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
  34051. */
  34052. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34053. /**
  34054. * Is this effect rendering to several color attachments ?
  34055. */
  34056. multiTarget?: boolean;
  34057. }
  34058. /**
  34059. * Effect containing vertex and fragment shader that can be executed on an object.
  34060. */
  34061. export class Effect implements IDisposable {
  34062. /**
  34063. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34064. */
  34065. static ShadersRepository: string;
  34066. /**
  34067. * Enable logging of the shader code when a compilation error occurs
  34068. */
  34069. static LogShaderCodeOnCompilationError: boolean;
  34070. /**
  34071. * Name of the effect.
  34072. */
  34073. name: any;
  34074. /**
  34075. * String container all the define statements that should be set on the shader.
  34076. */
  34077. defines: string;
  34078. /**
  34079. * Callback that will be called when the shader is compiled.
  34080. */
  34081. onCompiled: Nullable<(effect: Effect) => void>;
  34082. /**
  34083. * Callback that will be called if an error occurs during shader compilation.
  34084. */
  34085. onError: Nullable<(effect: Effect, errors: string) => void>;
  34086. /**
  34087. * Callback that will be called when effect is bound.
  34088. */
  34089. onBind: Nullable<(effect: Effect) => void>;
  34090. /**
  34091. * Unique ID of the effect.
  34092. */
  34093. uniqueId: number;
  34094. /**
  34095. * Observable that will be called when the shader is compiled.
  34096. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34097. */
  34098. onCompileObservable: Observable<Effect>;
  34099. /**
  34100. * Observable that will be called if an error occurs during shader compilation.
  34101. */
  34102. onErrorObservable: Observable<Effect>;
  34103. /** @hidden */
  34104. _onBindObservable: Nullable<Observable<Effect>>;
  34105. /**
  34106. * @hidden
  34107. * Specifies if the effect was previously ready
  34108. */
  34109. _wasPreviouslyReady: boolean;
  34110. /**
  34111. * Observable that will be called when effect is bound.
  34112. */
  34113. get onBindObservable(): Observable<Effect>;
  34114. /** @hidden */
  34115. _bonesComputationForcedToCPU: boolean;
  34116. /** @hidden */
  34117. _multiTarget: boolean;
  34118. private static _uniqueIdSeed;
  34119. private _engine;
  34120. private _uniformBuffersNames;
  34121. private _uniformBuffersNamesList;
  34122. private _uniformsNames;
  34123. private _samplerList;
  34124. private _samplers;
  34125. private _isReady;
  34126. private _compilationError;
  34127. private _allFallbacksProcessed;
  34128. private _attributesNames;
  34129. private _attributes;
  34130. private _attributeLocationByName;
  34131. private _uniforms;
  34132. /**
  34133. * Key for the effect.
  34134. * @hidden
  34135. */
  34136. _key: string;
  34137. private _indexParameters;
  34138. private _fallbacks;
  34139. private _vertexSourceCode;
  34140. private _fragmentSourceCode;
  34141. private _vertexSourceCodeOverride;
  34142. private _fragmentSourceCodeOverride;
  34143. private _transformFeedbackVaryings;
  34144. /**
  34145. * Compiled shader to webGL program.
  34146. * @hidden
  34147. */
  34148. _pipelineContext: Nullable<IPipelineContext>;
  34149. private _valueCache;
  34150. private static _baseCache;
  34151. /**
  34152. * Instantiates an effect.
  34153. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34154. * @param baseName Name of the effect.
  34155. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34156. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34157. * @param samplers List of sampler variables that will be passed to the shader.
  34158. * @param engine Engine to be used to render the effect
  34159. * @param defines Define statements to be added to the shader.
  34160. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34161. * @param onCompiled Callback that will be called when the shader is compiled.
  34162. * @param onError Callback that will be called if an error occurs during shader compilation.
  34163. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34164. */
  34165. 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);
  34166. private _useFinalCode;
  34167. /**
  34168. * Unique key for this effect
  34169. */
  34170. get key(): string;
  34171. /**
  34172. * If the effect has been compiled and prepared.
  34173. * @returns if the effect is compiled and prepared.
  34174. */
  34175. isReady(): boolean;
  34176. private _isReadyInternal;
  34177. /**
  34178. * The engine the effect was initialized with.
  34179. * @returns the engine.
  34180. */
  34181. getEngine(): Engine;
  34182. /**
  34183. * The pipeline context for this effect
  34184. * @returns the associated pipeline context
  34185. */
  34186. getPipelineContext(): Nullable<IPipelineContext>;
  34187. /**
  34188. * The set of names of attribute variables for the shader.
  34189. * @returns An array of attribute names.
  34190. */
  34191. getAttributesNames(): string[];
  34192. /**
  34193. * Returns the attribute at the given index.
  34194. * @param index The index of the attribute.
  34195. * @returns The location of the attribute.
  34196. */
  34197. getAttributeLocation(index: number): number;
  34198. /**
  34199. * Returns the attribute based on the name of the variable.
  34200. * @param name of the attribute to look up.
  34201. * @returns the attribute location.
  34202. */
  34203. getAttributeLocationByName(name: string): number;
  34204. /**
  34205. * The number of attributes.
  34206. * @returns the numnber of attributes.
  34207. */
  34208. getAttributesCount(): number;
  34209. /**
  34210. * Gets the index of a uniform variable.
  34211. * @param uniformName of the uniform to look up.
  34212. * @returns the index.
  34213. */
  34214. getUniformIndex(uniformName: string): number;
  34215. /**
  34216. * Returns the attribute based on the name of the variable.
  34217. * @param uniformName of the uniform to look up.
  34218. * @returns the location of the uniform.
  34219. */
  34220. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34221. /**
  34222. * Returns an array of sampler variable names
  34223. * @returns The array of sampler variable names.
  34224. */
  34225. getSamplers(): string[];
  34226. /**
  34227. * Returns an array of uniform variable names
  34228. * @returns The array of uniform variable names.
  34229. */
  34230. getUniformNames(): string[];
  34231. /**
  34232. * Returns an array of uniform buffer variable names
  34233. * @returns The array of uniform buffer variable names.
  34234. */
  34235. getUniformBuffersNames(): string[];
  34236. /**
  34237. * Returns the index parameters used to create the effect
  34238. * @returns The index parameters object
  34239. */
  34240. getIndexParameters(): any;
  34241. /**
  34242. * The error from the last compilation.
  34243. * @returns the error string.
  34244. */
  34245. getCompilationError(): string;
  34246. /**
  34247. * Gets a boolean indicating that all fallbacks were used during compilation
  34248. * @returns true if all fallbacks were used
  34249. */
  34250. allFallbacksProcessed(): boolean;
  34251. /**
  34252. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34253. * @param func The callback to be used.
  34254. */
  34255. executeWhenCompiled(func: (effect: Effect) => void): void;
  34256. private _checkIsReady;
  34257. private _loadShader;
  34258. /**
  34259. * Gets the vertex shader source code of this effect
  34260. */
  34261. get vertexSourceCode(): string;
  34262. /**
  34263. * Gets the fragment shader source code of this effect
  34264. */
  34265. get fragmentSourceCode(): string;
  34266. /**
  34267. * Recompiles the webGL program
  34268. * @param vertexSourceCode The source code for the vertex shader.
  34269. * @param fragmentSourceCode The source code for the fragment shader.
  34270. * @param onCompiled Callback called when completed.
  34271. * @param onError Callback called on error.
  34272. * @hidden
  34273. */
  34274. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34275. /**
  34276. * Prepares the effect
  34277. * @hidden
  34278. */
  34279. _prepareEffect(): void;
  34280. private _getShaderCodeAndErrorLine;
  34281. private _processCompilationErrors;
  34282. /**
  34283. * Checks if the effect is supported. (Must be called after compilation)
  34284. */
  34285. get isSupported(): boolean;
  34286. /**
  34287. * Binds a texture to the engine to be used as output of the shader.
  34288. * @param channel Name of the output variable.
  34289. * @param texture Texture to bind.
  34290. * @hidden
  34291. */
  34292. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34293. /**
  34294. * Sets a texture on the engine to be used in the shader.
  34295. * @param channel Name of the sampler variable.
  34296. * @param texture Texture to set.
  34297. */
  34298. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34299. /**
  34300. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34301. * @param channel Name of the sampler variable.
  34302. * @param texture Texture to set.
  34303. */
  34304. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34305. /**
  34306. * Sets an array of textures on the engine to be used in the shader.
  34307. * @param channel Name of the variable.
  34308. * @param textures Textures to set.
  34309. */
  34310. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34311. /**
  34312. * 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)
  34313. * @param channel Name of the sampler variable.
  34314. * @param postProcess Post process to get the input texture from.
  34315. */
  34316. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34317. /**
  34318. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34319. * 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)
  34320. * @param channel Name of the sampler variable.
  34321. * @param postProcess Post process to get the output texture from.
  34322. */
  34323. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34324. /** @hidden */
  34325. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34326. /** @hidden */
  34327. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34328. /** @hidden */
  34329. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34330. /** @hidden */
  34331. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34332. /**
  34333. * Binds a buffer to a uniform.
  34334. * @param buffer Buffer to bind.
  34335. * @param name Name of the uniform variable to bind to.
  34336. */
  34337. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34338. /**
  34339. * Binds block to a uniform.
  34340. * @param blockName Name of the block to bind.
  34341. * @param index Index to bind.
  34342. */
  34343. bindUniformBlock(blockName: string, index: number): void;
  34344. /**
  34345. * Sets an interger value on a uniform variable.
  34346. * @param uniformName Name of the variable.
  34347. * @param value Value to be set.
  34348. * @returns this effect.
  34349. */
  34350. setInt(uniformName: string, value: number): Effect;
  34351. /**
  34352. * Sets an int array on a uniform variable.
  34353. * @param uniformName Name of the variable.
  34354. * @param array array to be set.
  34355. * @returns this effect.
  34356. */
  34357. setIntArray(uniformName: string, array: Int32Array): Effect;
  34358. /**
  34359. * 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)
  34360. * @param uniformName Name of the variable.
  34361. * @param array array to be set.
  34362. * @returns this effect.
  34363. */
  34364. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34365. /**
  34366. * 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)
  34367. * @param uniformName Name of the variable.
  34368. * @param array array to be set.
  34369. * @returns this effect.
  34370. */
  34371. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34372. /**
  34373. * 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)
  34374. * @param uniformName Name of the variable.
  34375. * @param array array to be set.
  34376. * @returns this effect.
  34377. */
  34378. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34379. /**
  34380. * Sets an float array on a uniform variable.
  34381. * @param uniformName Name of the variable.
  34382. * @param array array to be set.
  34383. * @returns this effect.
  34384. */
  34385. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34386. /**
  34387. * 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)
  34388. * @param uniformName Name of the variable.
  34389. * @param array array to be set.
  34390. * @returns this effect.
  34391. */
  34392. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34393. /**
  34394. * 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)
  34395. * @param uniformName Name of the variable.
  34396. * @param array array to be set.
  34397. * @returns this effect.
  34398. */
  34399. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34400. /**
  34401. * 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)
  34402. * @param uniformName Name of the variable.
  34403. * @param array array to be set.
  34404. * @returns this effect.
  34405. */
  34406. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34407. /**
  34408. * Sets an array on a uniform variable.
  34409. * @param uniformName Name of the variable.
  34410. * @param array array to be set.
  34411. * @returns this effect.
  34412. */
  34413. setArray(uniformName: string, array: number[]): Effect;
  34414. /**
  34415. * 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)
  34416. * @param uniformName Name of the variable.
  34417. * @param array array to be set.
  34418. * @returns this effect.
  34419. */
  34420. setArray2(uniformName: string, array: number[]): Effect;
  34421. /**
  34422. * 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)
  34423. * @param uniformName Name of the variable.
  34424. * @param array array to be set.
  34425. * @returns this effect.
  34426. */
  34427. setArray3(uniformName: string, array: number[]): Effect;
  34428. /**
  34429. * 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)
  34430. * @param uniformName Name of the variable.
  34431. * @param array array to be set.
  34432. * @returns this effect.
  34433. */
  34434. setArray4(uniformName: string, array: number[]): Effect;
  34435. /**
  34436. * Sets matrices on a uniform variable.
  34437. * @param uniformName Name of the variable.
  34438. * @param matrices matrices to be set.
  34439. * @returns this effect.
  34440. */
  34441. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34442. /**
  34443. * Sets matrix on a uniform variable.
  34444. * @param uniformName Name of the variable.
  34445. * @param matrix matrix to be set.
  34446. * @returns this effect.
  34447. */
  34448. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34449. /**
  34450. * 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)
  34451. * @param uniformName Name of the variable.
  34452. * @param matrix matrix to be set.
  34453. * @returns this effect.
  34454. */
  34455. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34456. /**
  34457. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34458. * @param uniformName Name of the variable.
  34459. * @param matrix matrix to be set.
  34460. * @returns this effect.
  34461. */
  34462. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34463. /**
  34464. * Sets a float on a uniform variable.
  34465. * @param uniformName Name of the variable.
  34466. * @param value value to be set.
  34467. * @returns this effect.
  34468. */
  34469. setFloat(uniformName: string, value: number): Effect;
  34470. /**
  34471. * Sets a boolean on a uniform variable.
  34472. * @param uniformName Name of the variable.
  34473. * @param bool value to be set.
  34474. * @returns this effect.
  34475. */
  34476. setBool(uniformName: string, bool: boolean): Effect;
  34477. /**
  34478. * Sets a Vector2 on a uniform variable.
  34479. * @param uniformName Name of the variable.
  34480. * @param vector2 vector2 to be set.
  34481. * @returns this effect.
  34482. */
  34483. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34484. /**
  34485. * Sets a float2 on a uniform variable.
  34486. * @param uniformName Name of the variable.
  34487. * @param x First float in float2.
  34488. * @param y Second float in float2.
  34489. * @returns this effect.
  34490. */
  34491. setFloat2(uniformName: string, x: number, y: number): Effect;
  34492. /**
  34493. * Sets a Vector3 on a uniform variable.
  34494. * @param uniformName Name of the variable.
  34495. * @param vector3 Value to be set.
  34496. * @returns this effect.
  34497. */
  34498. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34499. /**
  34500. * Sets a float3 on a uniform variable.
  34501. * @param uniformName Name of the variable.
  34502. * @param x First float in float3.
  34503. * @param y Second float in float3.
  34504. * @param z Third float in float3.
  34505. * @returns this effect.
  34506. */
  34507. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34508. /**
  34509. * Sets a Vector4 on a uniform variable.
  34510. * @param uniformName Name of the variable.
  34511. * @param vector4 Value to be set.
  34512. * @returns this effect.
  34513. */
  34514. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34515. /**
  34516. * Sets a float4 on a uniform variable.
  34517. * @param uniformName Name of the variable.
  34518. * @param x First float in float4.
  34519. * @param y Second float in float4.
  34520. * @param z Third float in float4.
  34521. * @param w Fourth float in float4.
  34522. * @returns this effect.
  34523. */
  34524. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34525. /**
  34526. * Sets a Color3 on a uniform variable.
  34527. * @param uniformName Name of the variable.
  34528. * @param color3 Value to be set.
  34529. * @returns this effect.
  34530. */
  34531. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34532. /**
  34533. * Sets a Color4 on a uniform variable.
  34534. * @param uniformName Name of the variable.
  34535. * @param color3 Value to be set.
  34536. * @param alpha Alpha value to be set.
  34537. * @returns this effect.
  34538. */
  34539. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34540. /**
  34541. * Sets a Color4 on a uniform variable
  34542. * @param uniformName defines the name of the variable
  34543. * @param color4 defines the value to be set
  34544. * @returns this effect.
  34545. */
  34546. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34547. /** Release all associated resources */
  34548. dispose(): void;
  34549. /**
  34550. * This function will add a new shader to the shader store
  34551. * @param name the name of the shader
  34552. * @param pixelShader optional pixel shader content
  34553. * @param vertexShader optional vertex shader content
  34554. */
  34555. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34556. /**
  34557. * Store of each shader (The can be looked up using effect.key)
  34558. */
  34559. static ShadersStore: {
  34560. [key: string]: string;
  34561. };
  34562. /**
  34563. * Store of each included file for a shader (The can be looked up using effect.key)
  34564. */
  34565. static IncludesShadersStore: {
  34566. [key: string]: string;
  34567. };
  34568. /**
  34569. * Resets the cache of effects.
  34570. */
  34571. static ResetCache(): void;
  34572. }
  34573. }
  34574. declare module BABYLON {
  34575. /**
  34576. * Interface used to describe the capabilities of the engine relatively to the current browser
  34577. */
  34578. export interface EngineCapabilities {
  34579. /** Maximum textures units per fragment shader */
  34580. maxTexturesImageUnits: number;
  34581. /** Maximum texture units per vertex shader */
  34582. maxVertexTextureImageUnits: number;
  34583. /** Maximum textures units in the entire pipeline */
  34584. maxCombinedTexturesImageUnits: number;
  34585. /** Maximum texture size */
  34586. maxTextureSize: number;
  34587. /** Maximum texture samples */
  34588. maxSamples?: number;
  34589. /** Maximum cube texture size */
  34590. maxCubemapTextureSize: number;
  34591. /** Maximum render texture size */
  34592. maxRenderTextureSize: number;
  34593. /** Maximum number of vertex attributes */
  34594. maxVertexAttribs: number;
  34595. /** Maximum number of varyings */
  34596. maxVaryingVectors: number;
  34597. /** Maximum number of uniforms per vertex shader */
  34598. maxVertexUniformVectors: number;
  34599. /** Maximum number of uniforms per fragment shader */
  34600. maxFragmentUniformVectors: number;
  34601. /** Defines if standard derivates (dx/dy) are supported */
  34602. standardDerivatives: boolean;
  34603. /** Defines if s3tc texture compression is supported */
  34604. s3tc?: WEBGL_compressed_texture_s3tc;
  34605. /** Defines if pvrtc texture compression is supported */
  34606. pvrtc: any;
  34607. /** Defines if etc1 texture compression is supported */
  34608. etc1: any;
  34609. /** Defines if etc2 texture compression is supported */
  34610. etc2: any;
  34611. /** Defines if astc texture compression is supported */
  34612. astc: any;
  34613. /** Defines if float textures are supported */
  34614. textureFloat: boolean;
  34615. /** Defines if vertex array objects are supported */
  34616. vertexArrayObject: boolean;
  34617. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34618. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34619. /** Gets the maximum level of anisotropy supported */
  34620. maxAnisotropy: number;
  34621. /** Defines if instancing is supported */
  34622. instancedArrays: boolean;
  34623. /** Defines if 32 bits indices are supported */
  34624. uintIndices: boolean;
  34625. /** Defines if high precision shaders are supported */
  34626. highPrecisionShaderSupported: boolean;
  34627. /** Defines if depth reading in the fragment shader is supported */
  34628. fragmentDepthSupported: boolean;
  34629. /** Defines if float texture linear filtering is supported*/
  34630. textureFloatLinearFiltering: boolean;
  34631. /** Defines if rendering to float textures is supported */
  34632. textureFloatRender: boolean;
  34633. /** Defines if half float textures are supported*/
  34634. textureHalfFloat: boolean;
  34635. /** Defines if half float texture linear filtering is supported*/
  34636. textureHalfFloatLinearFiltering: boolean;
  34637. /** Defines if rendering to half float textures is supported */
  34638. textureHalfFloatRender: boolean;
  34639. /** Defines if textureLOD shader command is supported */
  34640. textureLOD: boolean;
  34641. /** Defines if draw buffers extension is supported */
  34642. drawBuffersExtension: boolean;
  34643. /** Defines if depth textures are supported */
  34644. depthTextureExtension: boolean;
  34645. /** Defines if float color buffer are supported */
  34646. colorBufferFloat: boolean;
  34647. /** Gets disjoint timer query extension (null if not supported) */
  34648. timerQuery?: EXT_disjoint_timer_query;
  34649. /** Defines if timestamp can be used with timer query */
  34650. canUseTimestampForTimerQuery: boolean;
  34651. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34652. multiview?: any;
  34653. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34654. oculusMultiview?: any;
  34655. /** Function used to let the system compiles shaders in background */
  34656. parallelShaderCompile?: {
  34657. COMPLETION_STATUS_KHR: number;
  34658. };
  34659. /** Max number of texture samples for MSAA */
  34660. maxMSAASamples: number;
  34661. /** Defines if the blend min max extension is supported */
  34662. blendMinMax: boolean;
  34663. }
  34664. }
  34665. declare module BABYLON {
  34666. /**
  34667. * @hidden
  34668. **/
  34669. export class DepthCullingState {
  34670. private _isDepthTestDirty;
  34671. private _isDepthMaskDirty;
  34672. private _isDepthFuncDirty;
  34673. private _isCullFaceDirty;
  34674. private _isCullDirty;
  34675. private _isZOffsetDirty;
  34676. private _isFrontFaceDirty;
  34677. private _depthTest;
  34678. private _depthMask;
  34679. private _depthFunc;
  34680. private _cull;
  34681. private _cullFace;
  34682. private _zOffset;
  34683. private _frontFace;
  34684. /**
  34685. * Initializes the state.
  34686. */
  34687. constructor();
  34688. get isDirty(): boolean;
  34689. get zOffset(): number;
  34690. set zOffset(value: number);
  34691. get cullFace(): Nullable<number>;
  34692. set cullFace(value: Nullable<number>);
  34693. get cull(): Nullable<boolean>;
  34694. set cull(value: Nullable<boolean>);
  34695. get depthFunc(): Nullable<number>;
  34696. set depthFunc(value: Nullable<number>);
  34697. get depthMask(): boolean;
  34698. set depthMask(value: boolean);
  34699. get depthTest(): boolean;
  34700. set depthTest(value: boolean);
  34701. get frontFace(): Nullable<number>;
  34702. set frontFace(value: Nullable<number>);
  34703. reset(): void;
  34704. apply(gl: WebGLRenderingContext): void;
  34705. }
  34706. }
  34707. declare module BABYLON {
  34708. /**
  34709. * @hidden
  34710. **/
  34711. export class StencilState {
  34712. /** 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 */
  34713. static readonly ALWAYS: number;
  34714. /** Passed to stencilOperation to specify that stencil value must be kept */
  34715. static readonly KEEP: number;
  34716. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34717. static readonly REPLACE: number;
  34718. private _isStencilTestDirty;
  34719. private _isStencilMaskDirty;
  34720. private _isStencilFuncDirty;
  34721. private _isStencilOpDirty;
  34722. private _stencilTest;
  34723. private _stencilMask;
  34724. private _stencilFunc;
  34725. private _stencilFuncRef;
  34726. private _stencilFuncMask;
  34727. private _stencilOpStencilFail;
  34728. private _stencilOpDepthFail;
  34729. private _stencilOpStencilDepthPass;
  34730. get isDirty(): boolean;
  34731. get stencilFunc(): number;
  34732. set stencilFunc(value: number);
  34733. get stencilFuncRef(): number;
  34734. set stencilFuncRef(value: number);
  34735. get stencilFuncMask(): number;
  34736. set stencilFuncMask(value: number);
  34737. get stencilOpStencilFail(): number;
  34738. set stencilOpStencilFail(value: number);
  34739. get stencilOpDepthFail(): number;
  34740. set stencilOpDepthFail(value: number);
  34741. get stencilOpStencilDepthPass(): number;
  34742. set stencilOpStencilDepthPass(value: number);
  34743. get stencilMask(): number;
  34744. set stencilMask(value: number);
  34745. get stencilTest(): boolean;
  34746. set stencilTest(value: boolean);
  34747. constructor();
  34748. reset(): void;
  34749. apply(gl: WebGLRenderingContext): void;
  34750. }
  34751. }
  34752. declare module BABYLON {
  34753. /**
  34754. * @hidden
  34755. **/
  34756. export class AlphaState {
  34757. private _isAlphaBlendDirty;
  34758. private _isBlendFunctionParametersDirty;
  34759. private _isBlendEquationParametersDirty;
  34760. private _isBlendConstantsDirty;
  34761. private _alphaBlend;
  34762. private _blendFunctionParameters;
  34763. private _blendEquationParameters;
  34764. private _blendConstants;
  34765. /**
  34766. * Initializes the state.
  34767. */
  34768. constructor();
  34769. get isDirty(): boolean;
  34770. get alphaBlend(): boolean;
  34771. set alphaBlend(value: boolean);
  34772. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34773. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34774. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34775. reset(): void;
  34776. apply(gl: WebGLRenderingContext): void;
  34777. }
  34778. }
  34779. declare module BABYLON {
  34780. /** @hidden */
  34781. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34782. attributeProcessor(attribute: string): string;
  34783. varyingProcessor(varying: string, isFragment: boolean): string;
  34784. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34785. }
  34786. }
  34787. declare module BABYLON {
  34788. /**
  34789. * Interface for attribute information associated with buffer instanciation
  34790. */
  34791. export interface InstancingAttributeInfo {
  34792. /**
  34793. * Name of the GLSL attribute
  34794. * if attribute index is not specified, this is used to retrieve the index from the effect
  34795. */
  34796. attributeName: string;
  34797. /**
  34798. * Index/offset of the attribute in the vertex shader
  34799. * if not specified, this will be computes from the name.
  34800. */
  34801. index?: number;
  34802. /**
  34803. * size of the attribute, 1, 2, 3 or 4
  34804. */
  34805. attributeSize: number;
  34806. /**
  34807. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34808. */
  34809. offset: number;
  34810. /**
  34811. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34812. * default to 1
  34813. */
  34814. divisor?: number;
  34815. /**
  34816. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34817. * default is FLOAT
  34818. */
  34819. attributeType?: number;
  34820. /**
  34821. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34822. */
  34823. normalized?: boolean;
  34824. }
  34825. }
  34826. declare module BABYLON {
  34827. interface ThinEngine {
  34828. /**
  34829. * Update a video texture
  34830. * @param texture defines the texture to update
  34831. * @param video defines the video element to use
  34832. * @param invertY defines if data must be stored with Y axis inverted
  34833. */
  34834. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34835. }
  34836. }
  34837. declare module BABYLON {
  34838. interface ThinEngine {
  34839. /**
  34840. * Creates a dynamic texture
  34841. * @param width defines the width of the texture
  34842. * @param height defines the height of the texture
  34843. * @param generateMipMaps defines if the engine should generate the mip levels
  34844. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34845. * @returns the dynamic texture inside an InternalTexture
  34846. */
  34847. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34848. /**
  34849. * Update the content of a dynamic texture
  34850. * @param texture defines the texture to update
  34851. * @param canvas defines the canvas containing the source
  34852. * @param invertY defines if data must be stored with Y axis inverted
  34853. * @param premulAlpha defines if alpha is stored as premultiplied
  34854. * @param format defines the format of the data
  34855. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34856. */
  34857. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34858. }
  34859. }
  34860. declare module BABYLON {
  34861. /**
  34862. * Settings for finer control over video usage
  34863. */
  34864. export interface VideoTextureSettings {
  34865. /**
  34866. * Applies `autoplay` to video, if specified
  34867. */
  34868. autoPlay?: boolean;
  34869. /**
  34870. * Applies `loop` to video, if specified
  34871. */
  34872. loop?: boolean;
  34873. /**
  34874. * Automatically updates internal texture from video at every frame in the render loop
  34875. */
  34876. autoUpdateTexture: boolean;
  34877. /**
  34878. * Image src displayed during the video loading or until the user interacts with the video.
  34879. */
  34880. poster?: string;
  34881. }
  34882. /**
  34883. * If you want to display a video in your scene, this is the special texture for that.
  34884. * This special texture works similar to other textures, with the exception of a few parameters.
  34885. * @see https://doc.babylonjs.com/how_to/video_texture
  34886. */
  34887. export class VideoTexture extends Texture {
  34888. /**
  34889. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34890. */
  34891. readonly autoUpdateTexture: boolean;
  34892. /**
  34893. * The video instance used by the texture internally
  34894. */
  34895. readonly video: HTMLVideoElement;
  34896. private _onUserActionRequestedObservable;
  34897. /**
  34898. * Event triggerd when a dom action is required by the user to play the video.
  34899. * This happens due to recent changes in browser policies preventing video to auto start.
  34900. */
  34901. get onUserActionRequestedObservable(): Observable<Texture>;
  34902. private _generateMipMaps;
  34903. private _stillImageCaptured;
  34904. private _displayingPosterTexture;
  34905. private _settings;
  34906. private _createInternalTextureOnEvent;
  34907. private _frameId;
  34908. private _currentSrc;
  34909. /**
  34910. * Creates a video texture.
  34911. * If you want to display a video in your scene, this is the special texture for that.
  34912. * This special texture works similar to other textures, with the exception of a few parameters.
  34913. * @see https://doc.babylonjs.com/how_to/video_texture
  34914. * @param name optional name, will detect from video source, if not defined
  34915. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34916. * @param scene is obviously the current scene.
  34917. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34918. * @param invertY is false by default but can be used to invert video on Y axis
  34919. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34920. * @param settings allows finer control over video usage
  34921. */
  34922. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34923. private _getName;
  34924. private _getVideo;
  34925. private _createInternalTexture;
  34926. private reset;
  34927. /**
  34928. * @hidden Internal method to initiate `update`.
  34929. */
  34930. _rebuild(): void;
  34931. /**
  34932. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34933. */
  34934. update(): void;
  34935. /**
  34936. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34937. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34938. */
  34939. updateTexture(isVisible: boolean): void;
  34940. protected _updateInternalTexture: () => void;
  34941. /**
  34942. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34943. * @param url New url.
  34944. */
  34945. updateURL(url: string): void;
  34946. /**
  34947. * Clones the texture.
  34948. * @returns the cloned texture
  34949. */
  34950. clone(): VideoTexture;
  34951. /**
  34952. * Dispose the texture and release its associated resources.
  34953. */
  34954. dispose(): void;
  34955. /**
  34956. * Creates a video texture straight from a stream.
  34957. * @param scene Define the scene the texture should be created in
  34958. * @param stream Define the stream the texture should be created from
  34959. * @returns The created video texture as a promise
  34960. */
  34961. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34962. /**
  34963. * Creates a video texture straight from your WebCam video feed.
  34964. * @param scene Define the scene the texture should be created in
  34965. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34966. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34967. * @returns The created video texture as a promise
  34968. */
  34969. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34970. minWidth: number;
  34971. maxWidth: number;
  34972. minHeight: number;
  34973. maxHeight: number;
  34974. deviceId: string;
  34975. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34976. /**
  34977. * Creates a video texture straight from your WebCam video feed.
  34978. * @param scene Define the scene the texture should be created in
  34979. * @param onReady Define a callback to triggered once the texture will be ready
  34980. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34981. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34982. */
  34983. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34984. minWidth: number;
  34985. maxWidth: number;
  34986. minHeight: number;
  34987. maxHeight: number;
  34988. deviceId: string;
  34989. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34990. }
  34991. }
  34992. declare module BABYLON {
  34993. /**
  34994. * Defines the interface used by objects working like Scene
  34995. * @hidden
  34996. */
  34997. export interface ISceneLike {
  34998. _addPendingData(data: any): void;
  34999. _removePendingData(data: any): void;
  35000. offlineProvider: IOfflineProvider;
  35001. }
  35002. /** Interface defining initialization parameters for Engine class */
  35003. export interface EngineOptions extends WebGLContextAttributes {
  35004. /**
  35005. * Defines if the engine should no exceed a specified device ratio
  35006. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35007. */
  35008. limitDeviceRatio?: number;
  35009. /**
  35010. * Defines if webvr should be enabled automatically
  35011. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35012. */
  35013. autoEnableWebVR?: boolean;
  35014. /**
  35015. * Defines if webgl2 should be turned off even if supported
  35016. * @see https://doc.babylonjs.com/features/webgl2
  35017. */
  35018. disableWebGL2Support?: boolean;
  35019. /**
  35020. * Defines if webaudio should be initialized as well
  35021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35022. */
  35023. audioEngine?: boolean;
  35024. /**
  35025. * Defines if animations should run using a deterministic lock step
  35026. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35027. */
  35028. deterministicLockstep?: boolean;
  35029. /** Defines the maximum steps to use with deterministic lock step mode */
  35030. lockstepMaxSteps?: number;
  35031. /** Defines the seconds between each deterministic lock step */
  35032. timeStep?: number;
  35033. /**
  35034. * Defines that engine should ignore context lost events
  35035. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35036. */
  35037. doNotHandleContextLost?: boolean;
  35038. /**
  35039. * Defines that engine should ignore modifying touch action attribute and style
  35040. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35041. */
  35042. doNotHandleTouchAction?: boolean;
  35043. /**
  35044. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35045. */
  35046. useHighPrecisionFloats?: boolean;
  35047. /**
  35048. * Make the canvas XR Compatible for XR sessions
  35049. */
  35050. xrCompatible?: boolean;
  35051. /**
  35052. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35053. */
  35054. useHighPrecisionMatrix?: boolean;
  35055. }
  35056. /**
  35057. * The base engine class (root of all engines)
  35058. */
  35059. export class ThinEngine {
  35060. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35061. static ExceptionList: ({
  35062. key: string;
  35063. capture: string;
  35064. captureConstraint: number;
  35065. targets: string[];
  35066. } | {
  35067. key: string;
  35068. capture: null;
  35069. captureConstraint: null;
  35070. targets: string[];
  35071. })[];
  35072. /** @hidden */
  35073. static _TextureLoaders: IInternalTextureLoader[];
  35074. /**
  35075. * Returns the current npm package of the sdk
  35076. */
  35077. static get NpmPackage(): string;
  35078. /**
  35079. * Returns the current version of the framework
  35080. */
  35081. static get Version(): string;
  35082. /**
  35083. * Returns a string describing the current engine
  35084. */
  35085. get description(): string;
  35086. /**
  35087. * Gets or sets the epsilon value used by collision engine
  35088. */
  35089. static CollisionsEpsilon: number;
  35090. /**
  35091. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35092. */
  35093. static get ShadersRepository(): string;
  35094. static set ShadersRepository(value: string);
  35095. /** @hidden */
  35096. _shaderProcessor: IShaderProcessor;
  35097. /**
  35098. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35099. */
  35100. forcePOTTextures: boolean;
  35101. /**
  35102. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35103. */
  35104. isFullscreen: boolean;
  35105. /**
  35106. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35107. */
  35108. cullBackFaces: boolean;
  35109. /**
  35110. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35111. */
  35112. renderEvenInBackground: boolean;
  35113. /**
  35114. * Gets or sets a boolean indicating that cache can be kept between frames
  35115. */
  35116. preventCacheWipeBetweenFrames: boolean;
  35117. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35118. validateShaderPrograms: boolean;
  35119. /**
  35120. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35121. * This can provide greater z depth for distant objects.
  35122. */
  35123. useReverseDepthBuffer: boolean;
  35124. /**
  35125. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35126. */
  35127. disableUniformBuffers: boolean;
  35128. /** @hidden */
  35129. _uniformBuffers: UniformBuffer[];
  35130. /**
  35131. * Gets a boolean indicating that the engine supports uniform buffers
  35132. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35133. */
  35134. get supportsUniformBuffers(): boolean;
  35135. /** @hidden */
  35136. _gl: WebGLRenderingContext;
  35137. /** @hidden */
  35138. _webGLVersion: number;
  35139. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35140. protected _windowIsBackground: boolean;
  35141. protected _creationOptions: EngineOptions;
  35142. protected _highPrecisionShadersAllowed: boolean;
  35143. /** @hidden */
  35144. get _shouldUseHighPrecisionShader(): boolean;
  35145. /**
  35146. * Gets a boolean indicating that only power of 2 textures are supported
  35147. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35148. */
  35149. get needPOTTextures(): boolean;
  35150. /** @hidden */
  35151. _badOS: boolean;
  35152. /** @hidden */
  35153. _badDesktopOS: boolean;
  35154. private _hardwareScalingLevel;
  35155. /** @hidden */
  35156. _caps: EngineCapabilities;
  35157. private _isStencilEnable;
  35158. private _glVersion;
  35159. private _glRenderer;
  35160. private _glVendor;
  35161. /** @hidden */
  35162. _videoTextureSupported: boolean;
  35163. protected _renderingQueueLaunched: boolean;
  35164. protected _activeRenderLoops: (() => void)[];
  35165. /**
  35166. * Observable signaled when a context lost event is raised
  35167. */
  35168. onContextLostObservable: Observable<ThinEngine>;
  35169. /**
  35170. * Observable signaled when a context restored event is raised
  35171. */
  35172. onContextRestoredObservable: Observable<ThinEngine>;
  35173. private _onContextLost;
  35174. private _onContextRestored;
  35175. protected _contextWasLost: boolean;
  35176. /** @hidden */
  35177. _doNotHandleContextLost: boolean;
  35178. /**
  35179. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35180. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35181. */
  35182. get doNotHandleContextLost(): boolean;
  35183. set doNotHandleContextLost(value: boolean);
  35184. /**
  35185. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35186. */
  35187. disableVertexArrayObjects: boolean;
  35188. /** @hidden */
  35189. protected _colorWrite: boolean;
  35190. /** @hidden */
  35191. protected _colorWriteChanged: boolean;
  35192. /** @hidden */
  35193. protected _depthCullingState: DepthCullingState;
  35194. /** @hidden */
  35195. protected _stencilState: StencilState;
  35196. /** @hidden */
  35197. _alphaState: AlphaState;
  35198. /** @hidden */
  35199. _alphaMode: number;
  35200. /** @hidden */
  35201. _alphaEquation: number;
  35202. /** @hidden */
  35203. _internalTexturesCache: InternalTexture[];
  35204. /** @hidden */
  35205. protected _activeChannel: number;
  35206. private _currentTextureChannel;
  35207. /** @hidden */
  35208. protected _boundTexturesCache: {
  35209. [key: string]: Nullable<InternalTexture>;
  35210. };
  35211. /** @hidden */
  35212. protected _currentEffect: Nullable<Effect>;
  35213. /** @hidden */
  35214. protected _currentProgram: Nullable<WebGLProgram>;
  35215. private _compiledEffects;
  35216. private _vertexAttribArraysEnabled;
  35217. /** @hidden */
  35218. protected _cachedViewport: Nullable<IViewportLike>;
  35219. private _cachedVertexArrayObject;
  35220. /** @hidden */
  35221. protected _cachedVertexBuffers: any;
  35222. /** @hidden */
  35223. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35224. /** @hidden */
  35225. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35226. /** @hidden */
  35227. _currentRenderTarget: Nullable<InternalTexture>;
  35228. private _uintIndicesCurrentlySet;
  35229. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35230. /** @hidden */
  35231. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35232. /** @hidden */
  35233. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35234. private _currentBufferPointers;
  35235. private _currentInstanceLocations;
  35236. private _currentInstanceBuffers;
  35237. private _textureUnits;
  35238. /** @hidden */
  35239. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35240. /** @hidden */
  35241. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35242. /** @hidden */
  35243. _boundRenderFunction: any;
  35244. private _vaoRecordInProgress;
  35245. private _mustWipeVertexAttributes;
  35246. private _emptyTexture;
  35247. private _emptyCubeTexture;
  35248. private _emptyTexture3D;
  35249. private _emptyTexture2DArray;
  35250. /** @hidden */
  35251. _frameHandler: number;
  35252. private _nextFreeTextureSlots;
  35253. private _maxSimultaneousTextures;
  35254. private _activeRequests;
  35255. /** @hidden */
  35256. _transformTextureUrl: Nullable<(url: string) => string>;
  35257. protected get _supportsHardwareTextureRescaling(): boolean;
  35258. private _framebufferDimensionsObject;
  35259. /**
  35260. * sets the object from which width and height will be taken from when getting render width and height
  35261. * Will fallback to the gl object
  35262. * @param dimensions the framebuffer width and height that will be used.
  35263. */
  35264. set framebufferDimensionsObject(dimensions: Nullable<{
  35265. framebufferWidth: number;
  35266. framebufferHeight: number;
  35267. }>);
  35268. /**
  35269. * Gets the current viewport
  35270. */
  35271. get currentViewport(): Nullable<IViewportLike>;
  35272. /**
  35273. * Gets the default empty texture
  35274. */
  35275. get emptyTexture(): InternalTexture;
  35276. /**
  35277. * Gets the default empty 3D texture
  35278. */
  35279. get emptyTexture3D(): InternalTexture;
  35280. /**
  35281. * Gets the default empty 2D array texture
  35282. */
  35283. get emptyTexture2DArray(): InternalTexture;
  35284. /**
  35285. * Gets the default empty cube texture
  35286. */
  35287. get emptyCubeTexture(): InternalTexture;
  35288. /**
  35289. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35290. */
  35291. readonly premultipliedAlpha: boolean;
  35292. /**
  35293. * Observable event triggered before each texture is initialized
  35294. */
  35295. onBeforeTextureInitObservable: Observable<Texture>;
  35296. /**
  35297. * Creates a new engine
  35298. * @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
  35299. * @param antialias defines enable antialiasing (default: false)
  35300. * @param options defines further options to be sent to the getContext() function
  35301. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35302. */
  35303. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35304. private _rebuildInternalTextures;
  35305. private _rebuildEffects;
  35306. /**
  35307. * Gets a boolean indicating if all created effects are ready
  35308. * @returns true if all effects are ready
  35309. */
  35310. areAllEffectsReady(): boolean;
  35311. protected _rebuildBuffers(): void;
  35312. protected _initGLContext(): void;
  35313. /**
  35314. * Gets version of the current webGL context
  35315. */
  35316. get webGLVersion(): number;
  35317. /**
  35318. * Gets a string idenfifying the name of the class
  35319. * @returns "Engine" string
  35320. */
  35321. getClassName(): string;
  35322. /**
  35323. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35324. */
  35325. get isStencilEnable(): boolean;
  35326. /** @hidden */
  35327. _prepareWorkingCanvas(): void;
  35328. /**
  35329. * Reset the texture cache to empty state
  35330. */
  35331. resetTextureCache(): void;
  35332. /**
  35333. * Gets an object containing information about the current webGL context
  35334. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35335. */
  35336. getGlInfo(): {
  35337. vendor: string;
  35338. renderer: string;
  35339. version: string;
  35340. };
  35341. /**
  35342. * Defines the hardware scaling level.
  35343. * By default the hardware scaling level is computed from the window device ratio.
  35344. * 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.
  35345. * @param level defines the level to use
  35346. */
  35347. setHardwareScalingLevel(level: number): void;
  35348. /**
  35349. * Gets the current hardware scaling level.
  35350. * By default the hardware scaling level is computed from the window device ratio.
  35351. * 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.
  35352. * @returns a number indicating the current hardware scaling level
  35353. */
  35354. getHardwareScalingLevel(): number;
  35355. /**
  35356. * Gets the list of loaded textures
  35357. * @returns an array containing all loaded textures
  35358. */
  35359. getLoadedTexturesCache(): InternalTexture[];
  35360. /**
  35361. * Gets the object containing all engine capabilities
  35362. * @returns the EngineCapabilities object
  35363. */
  35364. getCaps(): EngineCapabilities;
  35365. /**
  35366. * stop executing a render loop function and remove it from the execution array
  35367. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35368. */
  35369. stopRenderLoop(renderFunction?: () => void): void;
  35370. /** @hidden */
  35371. _renderLoop(): void;
  35372. /**
  35373. * Gets the HTML canvas attached with the current webGL context
  35374. * @returns a HTML canvas
  35375. */
  35376. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35377. /**
  35378. * Gets host window
  35379. * @returns the host window object
  35380. */
  35381. getHostWindow(): Nullable<Window>;
  35382. /**
  35383. * Gets the current render width
  35384. * @param useScreen defines if screen size must be used (or the current render target if any)
  35385. * @returns a number defining the current render width
  35386. */
  35387. getRenderWidth(useScreen?: boolean): number;
  35388. /**
  35389. * Gets the current render height
  35390. * @param useScreen defines if screen size must be used (or the current render target if any)
  35391. * @returns a number defining the current render height
  35392. */
  35393. getRenderHeight(useScreen?: boolean): number;
  35394. /**
  35395. * Can be used to override the current requestAnimationFrame requester.
  35396. * @hidden
  35397. */
  35398. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35399. /**
  35400. * Register and execute a render loop. The engine can have more than one render function
  35401. * @param renderFunction defines the function to continuously execute
  35402. */
  35403. runRenderLoop(renderFunction: () => void): void;
  35404. /**
  35405. * Clear the current render buffer or the current render target (if any is set up)
  35406. * @param color defines the color to use
  35407. * @param backBuffer defines if the back buffer must be cleared
  35408. * @param depth defines if the depth buffer must be cleared
  35409. * @param stencil defines if the stencil buffer must be cleared
  35410. */
  35411. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35412. private _viewportCached;
  35413. /** @hidden */
  35414. _viewport(x: number, y: number, width: number, height: number): void;
  35415. /**
  35416. * Set the WebGL's viewport
  35417. * @param viewport defines the viewport element to be used
  35418. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35419. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35420. */
  35421. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35422. /**
  35423. * Begin a new frame
  35424. */
  35425. beginFrame(): void;
  35426. /**
  35427. * Enf the current frame
  35428. */
  35429. endFrame(): void;
  35430. /**
  35431. * Resize the view according to the canvas' size
  35432. */
  35433. resize(): void;
  35434. /**
  35435. * Force a specific size of the canvas
  35436. * @param width defines the new canvas' width
  35437. * @param height defines the new canvas' height
  35438. * @returns true if the size was changed
  35439. */
  35440. setSize(width: number, height: number): boolean;
  35441. /**
  35442. * Binds the frame buffer to the specified texture.
  35443. * @param texture The texture to render to or null for the default canvas
  35444. * @param faceIndex The face of the texture to render to in case of cube texture
  35445. * @param requiredWidth The width of the target to render to
  35446. * @param requiredHeight The height of the target to render to
  35447. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35448. * @param lodLevel defines the lod level to bind to the frame buffer
  35449. * @param layer defines the 2d array index to bind to frame buffer to
  35450. */
  35451. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35452. /** @hidden */
  35453. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35454. /**
  35455. * Unbind the current render target texture from the webGL context
  35456. * @param texture defines the render target texture to unbind
  35457. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35458. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35459. */
  35460. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35461. /**
  35462. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35463. */
  35464. flushFramebuffer(): void;
  35465. /**
  35466. * Unbind the current render target and bind the default framebuffer
  35467. */
  35468. restoreDefaultFramebuffer(): void;
  35469. /** @hidden */
  35470. protected _resetVertexBufferBinding(): void;
  35471. /**
  35472. * Creates a vertex buffer
  35473. * @param data the data for the vertex buffer
  35474. * @returns the new WebGL static buffer
  35475. */
  35476. createVertexBuffer(data: DataArray): DataBuffer;
  35477. private _createVertexBuffer;
  35478. /**
  35479. * Creates a dynamic vertex buffer
  35480. * @param data the data for the dynamic vertex buffer
  35481. * @returns the new WebGL dynamic buffer
  35482. */
  35483. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35484. protected _resetIndexBufferBinding(): void;
  35485. /**
  35486. * Creates a new index buffer
  35487. * @param indices defines the content of the index buffer
  35488. * @param updatable defines if the index buffer must be updatable
  35489. * @returns a new webGL buffer
  35490. */
  35491. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35492. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35493. /**
  35494. * Bind a webGL buffer to the webGL context
  35495. * @param buffer defines the buffer to bind
  35496. */
  35497. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35498. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35499. private bindBuffer;
  35500. /**
  35501. * update the bound buffer with the given data
  35502. * @param data defines the data to update
  35503. */
  35504. updateArrayBuffer(data: Float32Array): void;
  35505. private _vertexAttribPointer;
  35506. /** @hidden */
  35507. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35508. private _bindVertexBuffersAttributes;
  35509. /**
  35510. * Records a vertex array object
  35511. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35512. * @param vertexBuffers defines the list of vertex buffers to store
  35513. * @param indexBuffer defines the index buffer to store
  35514. * @param effect defines the effect to store
  35515. * @returns the new vertex array object
  35516. */
  35517. recordVertexArrayObject(vertexBuffers: {
  35518. [key: string]: VertexBuffer;
  35519. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35520. /**
  35521. * Bind a specific vertex array object
  35522. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35523. * @param vertexArrayObject defines the vertex array object to bind
  35524. * @param indexBuffer defines the index buffer to bind
  35525. */
  35526. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35527. /**
  35528. * Bind webGl buffers directly to the webGL context
  35529. * @param vertexBuffer defines the vertex buffer to bind
  35530. * @param indexBuffer defines the index buffer to bind
  35531. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35532. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35533. * @param effect defines the effect associated with the vertex buffer
  35534. */
  35535. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35536. private _unbindVertexArrayObject;
  35537. /**
  35538. * Bind a list of vertex buffers to the webGL context
  35539. * @param vertexBuffers defines the list of vertex buffers to bind
  35540. * @param indexBuffer defines the index buffer to bind
  35541. * @param effect defines the effect associated with the vertex buffers
  35542. */
  35543. bindBuffers(vertexBuffers: {
  35544. [key: string]: Nullable<VertexBuffer>;
  35545. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35546. /**
  35547. * Unbind all instance attributes
  35548. */
  35549. unbindInstanceAttributes(): void;
  35550. /**
  35551. * Release and free the memory of a vertex array object
  35552. * @param vao defines the vertex array object to delete
  35553. */
  35554. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35555. /** @hidden */
  35556. _releaseBuffer(buffer: DataBuffer): boolean;
  35557. protected _deleteBuffer(buffer: DataBuffer): void;
  35558. /**
  35559. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35560. * @param instancesBuffer defines the webGL buffer to update and bind
  35561. * @param data defines the data to store in the buffer
  35562. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35563. */
  35564. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35565. /**
  35566. * Bind the content of a webGL buffer used with instantiation
  35567. * @param instancesBuffer defines the webGL buffer to bind
  35568. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35569. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35570. */
  35571. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35572. /**
  35573. * Disable the instance attribute corresponding to the name in parameter
  35574. * @param name defines the name of the attribute to disable
  35575. */
  35576. disableInstanceAttributeByName(name: string): void;
  35577. /**
  35578. * Disable the instance attribute corresponding to the location in parameter
  35579. * @param attributeLocation defines the attribute location of the attribute to disable
  35580. */
  35581. disableInstanceAttribute(attributeLocation: number): void;
  35582. /**
  35583. * Disable the attribute corresponding to the location in parameter
  35584. * @param attributeLocation defines the attribute location of the attribute to disable
  35585. */
  35586. disableAttributeByIndex(attributeLocation: number): void;
  35587. /**
  35588. * Send a draw order
  35589. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35590. * @param indexStart defines the starting index
  35591. * @param indexCount defines the number of index to draw
  35592. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35593. */
  35594. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35595. /**
  35596. * Draw a list of points
  35597. * @param verticesStart defines the index of first vertex to draw
  35598. * @param verticesCount defines the count of vertices to draw
  35599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35600. */
  35601. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35602. /**
  35603. * Draw a list of unindexed primitives
  35604. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35605. * @param verticesStart defines the index of first vertex to draw
  35606. * @param verticesCount defines the count of vertices to draw
  35607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35608. */
  35609. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35610. /**
  35611. * Draw a list of indexed primitives
  35612. * @param fillMode defines the primitive to use
  35613. * @param indexStart defines the starting index
  35614. * @param indexCount defines the number of index to draw
  35615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35616. */
  35617. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35618. /**
  35619. * Draw a list of unindexed primitives
  35620. * @param fillMode defines the primitive to use
  35621. * @param verticesStart defines the index of first vertex to draw
  35622. * @param verticesCount defines the count of vertices to draw
  35623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35624. */
  35625. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35626. private _drawMode;
  35627. /** @hidden */
  35628. protected _reportDrawCall(): void;
  35629. /** @hidden */
  35630. _releaseEffect(effect: Effect): void;
  35631. /** @hidden */
  35632. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35633. /**
  35634. * Create a new effect (used to store vertex/fragment shaders)
  35635. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35636. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35637. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35638. * @param samplers defines an array of string used to represent textures
  35639. * @param defines defines the string containing the defines to use to compile the shaders
  35640. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35641. * @param onCompiled defines a function to call when the effect creation is successful
  35642. * @param onError defines a function to call when the effect creation has failed
  35643. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35644. * @returns the new Effect
  35645. */
  35646. 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;
  35647. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35648. private _compileShader;
  35649. private _compileRawShader;
  35650. /** @hidden */
  35651. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35652. /**
  35653. * Directly creates a webGL program
  35654. * @param pipelineContext defines the pipeline context to attach to
  35655. * @param vertexCode defines the vertex shader code to use
  35656. * @param fragmentCode defines the fragment shader code to use
  35657. * @param context defines the webGL context to use (if not set, the current one will be used)
  35658. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35659. * @returns the new webGL program
  35660. */
  35661. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35662. /**
  35663. * Creates a webGL program
  35664. * @param pipelineContext defines the pipeline context to attach to
  35665. * @param vertexCode defines the vertex shader code to use
  35666. * @param fragmentCode defines the fragment shader code to use
  35667. * @param defines defines the string containing the defines to use to compile the shaders
  35668. * @param context defines the webGL context to use (if not set, the current one will be used)
  35669. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35670. * @returns the new webGL program
  35671. */
  35672. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35673. /**
  35674. * Creates a new pipeline context
  35675. * @returns the new pipeline
  35676. */
  35677. createPipelineContext(): IPipelineContext;
  35678. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35679. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35680. /** @hidden */
  35681. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35682. /** @hidden */
  35683. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35684. /** @hidden */
  35685. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35686. /**
  35687. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35688. * @param pipelineContext defines the pipeline context to use
  35689. * @param uniformsNames defines the list of uniform names
  35690. * @returns an array of webGL uniform locations
  35691. */
  35692. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35693. /**
  35694. * Gets the lsit of active attributes for a given webGL program
  35695. * @param pipelineContext defines the pipeline context to use
  35696. * @param attributesNames defines the list of attribute names to get
  35697. * @returns an array of indices indicating the offset of each attribute
  35698. */
  35699. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35700. /**
  35701. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35702. * @param effect defines the effect to activate
  35703. */
  35704. enableEffect(effect: Nullable<Effect>): void;
  35705. /**
  35706. * Set the value of an uniform to a number (int)
  35707. * @param uniform defines the webGL uniform location where to store the value
  35708. * @param value defines the int number to store
  35709. */
  35710. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35711. /**
  35712. * Set the value of an uniform to an array of int32
  35713. * @param uniform defines the webGL uniform location where to store the value
  35714. * @param array defines the array of int32 to store
  35715. */
  35716. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35717. /**
  35718. * Set the value of an uniform to an array of int32 (stored as vec2)
  35719. * @param uniform defines the webGL uniform location where to store the value
  35720. * @param array defines the array of int32 to store
  35721. */
  35722. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35723. /**
  35724. * Set the value of an uniform to an array of int32 (stored as vec3)
  35725. * @param uniform defines the webGL uniform location where to store the value
  35726. * @param array defines the array of int32 to store
  35727. */
  35728. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35729. /**
  35730. * Set the value of an uniform to an array of int32 (stored as vec4)
  35731. * @param uniform defines the webGL uniform location where to store the value
  35732. * @param array defines the array of int32 to store
  35733. */
  35734. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35735. /**
  35736. * Set the value of an uniform to an array of number
  35737. * @param uniform defines the webGL uniform location where to store the value
  35738. * @param array defines the array of number to store
  35739. */
  35740. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35741. /**
  35742. * Set the value of an uniform to an array of number (stored as vec2)
  35743. * @param uniform defines the webGL uniform location where to store the value
  35744. * @param array defines the array of number to store
  35745. */
  35746. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35747. /**
  35748. * Set the value of an uniform to an array of number (stored as vec3)
  35749. * @param uniform defines the webGL uniform location where to store the value
  35750. * @param array defines the array of number to store
  35751. */
  35752. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35753. /**
  35754. * Set the value of an uniform to an array of number (stored as vec4)
  35755. * @param uniform defines the webGL uniform location where to store the value
  35756. * @param array defines the array of number to store
  35757. */
  35758. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35759. /**
  35760. * Set the value of an uniform to an array of float32 (stored as matrices)
  35761. * @param uniform defines the webGL uniform location where to store the value
  35762. * @param matrices defines the array of float32 to store
  35763. */
  35764. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35765. /**
  35766. * Set the value of an uniform to a matrix (3x3)
  35767. * @param uniform defines the webGL uniform location where to store the value
  35768. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35769. */
  35770. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35771. /**
  35772. * Set the value of an uniform to a matrix (2x2)
  35773. * @param uniform defines the webGL uniform location where to store the value
  35774. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35775. */
  35776. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35777. /**
  35778. * Set the value of an uniform to a number (float)
  35779. * @param uniform defines the webGL uniform location where to store the value
  35780. * @param value defines the float number to store
  35781. */
  35782. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35783. /**
  35784. * Set the value of an uniform to a vec2
  35785. * @param uniform defines the webGL uniform location where to store the value
  35786. * @param x defines the 1st component of the value
  35787. * @param y defines the 2nd component of the value
  35788. */
  35789. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35790. /**
  35791. * Set the value of an uniform to a vec3
  35792. * @param uniform defines the webGL uniform location where to store the value
  35793. * @param x defines the 1st component of the value
  35794. * @param y defines the 2nd component of the value
  35795. * @param z defines the 3rd component of the value
  35796. */
  35797. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35798. /**
  35799. * Set the value of an uniform to a vec4
  35800. * @param uniform defines the webGL uniform location where to store the value
  35801. * @param x defines the 1st component of the value
  35802. * @param y defines the 2nd component of the value
  35803. * @param z defines the 3rd component of the value
  35804. * @param w defines the 4th component of the value
  35805. */
  35806. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35807. /**
  35808. * Apply all cached states (depth, culling, stencil and alpha)
  35809. */
  35810. applyStates(): void;
  35811. /**
  35812. * Enable or disable color writing
  35813. * @param enable defines the state to set
  35814. */
  35815. setColorWrite(enable: boolean): void;
  35816. /**
  35817. * Gets a boolean indicating if color writing is enabled
  35818. * @returns the current color writing state
  35819. */
  35820. getColorWrite(): boolean;
  35821. /**
  35822. * Gets the depth culling state manager
  35823. */
  35824. get depthCullingState(): DepthCullingState;
  35825. /**
  35826. * Gets the alpha state manager
  35827. */
  35828. get alphaState(): AlphaState;
  35829. /**
  35830. * Gets the stencil state manager
  35831. */
  35832. get stencilState(): StencilState;
  35833. /**
  35834. * Clears the list of texture accessible through engine.
  35835. * This can help preventing texture load conflict due to name collision.
  35836. */
  35837. clearInternalTexturesCache(): void;
  35838. /**
  35839. * Force the entire cache to be cleared
  35840. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35841. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35842. */
  35843. wipeCaches(bruteForce?: boolean): void;
  35844. /** @hidden */
  35845. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35846. min: number;
  35847. mag: number;
  35848. };
  35849. /** @hidden */
  35850. _createTexture(): WebGLTexture;
  35851. /**
  35852. * Usually called from Texture.ts.
  35853. * Passed information to create a WebGLTexture
  35854. * @param url defines a value which contains one of the following:
  35855. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35856. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35857. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35858. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35859. * @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)
  35860. * @param scene needed for loading to the correct scene
  35861. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35862. * @param onLoad optional callback to be called upon successful completion
  35863. * @param onError optional callback to be called upon failure
  35864. * @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
  35865. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35866. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35867. * @param forcedExtension defines the extension to use to pick the right loader
  35868. * @param mimeType defines an optional mime type
  35869. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35870. */
  35871. 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): InternalTexture;
  35872. /**
  35873. * Loads an image as an HTMLImageElement.
  35874. * @param input url string, ArrayBuffer, or Blob to load
  35875. * @param onLoad callback called when the image successfully loads
  35876. * @param onError callback called when the image fails to load
  35877. * @param offlineProvider offline provider for caching
  35878. * @param mimeType optional mime type
  35879. * @returns the HTMLImageElement of the loaded image
  35880. * @hidden
  35881. */
  35882. 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>;
  35883. /**
  35884. * @hidden
  35885. */
  35886. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35887. private _unpackFlipYCached;
  35888. /**
  35889. * In case you are sharing the context with other applications, it might
  35890. * be interested to not cache the unpack flip y state to ensure a consistent
  35891. * value would be set.
  35892. */
  35893. enableUnpackFlipYCached: boolean;
  35894. /** @hidden */
  35895. _unpackFlipY(value: boolean): void;
  35896. /** @hidden */
  35897. _getUnpackAlignement(): number;
  35898. private _getTextureTarget;
  35899. /**
  35900. * Update the sampling mode of a given texture
  35901. * @param samplingMode defines the required sampling mode
  35902. * @param texture defines the texture to update
  35903. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35904. */
  35905. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35906. /**
  35907. * Update the sampling mode of a given texture
  35908. * @param texture defines the texture to update
  35909. * @param wrapU defines the texture wrap mode of the u coordinates
  35910. * @param wrapV defines the texture wrap mode of the v coordinates
  35911. * @param wrapR defines the texture wrap mode of the r coordinates
  35912. */
  35913. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35914. /** @hidden */
  35915. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35916. width: number;
  35917. height: number;
  35918. layers?: number;
  35919. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35920. /** @hidden */
  35921. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35922. /** @hidden */
  35923. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35924. /**
  35925. * Update a portion of an internal texture
  35926. * @param texture defines the texture to update
  35927. * @param imageData defines the data to store into the texture
  35928. * @param xOffset defines the x coordinates of the update rectangle
  35929. * @param yOffset defines the y coordinates of the update rectangle
  35930. * @param width defines the width of the update rectangle
  35931. * @param height defines the height of the update rectangle
  35932. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35933. * @param lod defines the lod level to update (0 by default)
  35934. */
  35935. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35936. /** @hidden */
  35937. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35938. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35939. private _prepareWebGLTexture;
  35940. /** @hidden */
  35941. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35942. private _getDepthStencilBuffer;
  35943. /** @hidden */
  35944. _releaseFramebufferObjects(texture: InternalTexture): void;
  35945. /** @hidden */
  35946. _releaseTexture(texture: InternalTexture): void;
  35947. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35948. protected _setProgram(program: WebGLProgram): void;
  35949. protected _boundUniforms: {
  35950. [key: number]: WebGLUniformLocation;
  35951. };
  35952. /**
  35953. * Binds an effect to the webGL context
  35954. * @param effect defines the effect to bind
  35955. */
  35956. bindSamplers(effect: Effect): void;
  35957. private _activateCurrentTexture;
  35958. /** @hidden */
  35959. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35960. /** @hidden */
  35961. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35962. /**
  35963. * Unbind all textures from the webGL context
  35964. */
  35965. unbindAllTextures(): void;
  35966. /**
  35967. * Sets a texture to the according uniform.
  35968. * @param channel The texture channel
  35969. * @param uniform The uniform to set
  35970. * @param texture The texture to apply
  35971. */
  35972. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35973. private _bindSamplerUniformToChannel;
  35974. private _getTextureWrapMode;
  35975. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35976. /**
  35977. * Sets an array of texture to the webGL context
  35978. * @param channel defines the channel where the texture array must be set
  35979. * @param uniform defines the associated uniform location
  35980. * @param textures defines the array of textures to bind
  35981. */
  35982. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35983. /** @hidden */
  35984. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35985. private _setTextureParameterFloat;
  35986. private _setTextureParameterInteger;
  35987. /**
  35988. * Unbind all vertex attributes from the webGL context
  35989. */
  35990. unbindAllAttributes(): void;
  35991. /**
  35992. * 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
  35993. */
  35994. releaseEffects(): void;
  35995. /**
  35996. * Dispose and release all associated resources
  35997. */
  35998. dispose(): void;
  35999. /**
  36000. * Attach a new callback raised when context lost event is fired
  36001. * @param callback defines the callback to call
  36002. */
  36003. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36004. /**
  36005. * Attach a new callback raised when context restored event is fired
  36006. * @param callback defines the callback to call
  36007. */
  36008. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36009. /**
  36010. * Get the current error code of the webGL context
  36011. * @returns the error code
  36012. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36013. */
  36014. getError(): number;
  36015. private _canRenderToFloatFramebuffer;
  36016. private _canRenderToHalfFloatFramebuffer;
  36017. private _canRenderToFramebuffer;
  36018. /** @hidden */
  36019. _getWebGLTextureType(type: number): number;
  36020. /** @hidden */
  36021. _getInternalFormat(format: number): number;
  36022. /** @hidden */
  36023. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36024. /** @hidden */
  36025. _getRGBAMultiSampleBufferFormat(type: number): number;
  36026. /** @hidden */
  36027. _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;
  36028. /**
  36029. * Loads a file from a url
  36030. * @param url url to load
  36031. * @param onSuccess callback called when the file successfully loads
  36032. * @param onProgress callback called while file is loading (if the server supports this mode)
  36033. * @param offlineProvider defines the offline provider for caching
  36034. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36035. * @param onError callback called when the file fails to load
  36036. * @returns a file request object
  36037. * @hidden
  36038. */
  36039. 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;
  36040. /**
  36041. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36042. * @param x defines the x coordinate of the rectangle where pixels must be read
  36043. * @param y defines the y coordinate of the rectangle where pixels must be read
  36044. * @param width defines the width of the rectangle where pixels must be read
  36045. * @param height defines the height of the rectangle where pixels must be read
  36046. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36047. * @returns a Uint8Array containing RGBA colors
  36048. */
  36049. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36050. private static _isSupported;
  36051. /**
  36052. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36053. * @returns true if the engine can be created
  36054. * @ignorenaming
  36055. */
  36056. static isSupported(): boolean;
  36057. /**
  36058. * Find the next highest power of two.
  36059. * @param x Number to start search from.
  36060. * @return Next highest power of two.
  36061. */
  36062. static CeilingPOT(x: number): number;
  36063. /**
  36064. * Find the next lowest power of two.
  36065. * @param x Number to start search from.
  36066. * @return Next lowest power of two.
  36067. */
  36068. static FloorPOT(x: number): number;
  36069. /**
  36070. * Find the nearest power of two.
  36071. * @param x Number to start search from.
  36072. * @return Next nearest power of two.
  36073. */
  36074. static NearestPOT(x: number): number;
  36075. /**
  36076. * Get the closest exponent of two
  36077. * @param value defines the value to approximate
  36078. * @param max defines the maximum value to return
  36079. * @param mode defines how to define the closest value
  36080. * @returns closest exponent of two of the given value
  36081. */
  36082. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36083. /**
  36084. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36085. * @param func - the function to be called
  36086. * @param requester - the object that will request the next frame. Falls back to window.
  36087. * @returns frame number
  36088. */
  36089. static QueueNewFrame(func: () => void, requester?: any): number;
  36090. /**
  36091. * Gets host document
  36092. * @returns the host document object
  36093. */
  36094. getHostDocument(): Nullable<Document>;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Class representing spherical harmonics coefficients to the 3rd degree
  36100. */
  36101. export class SphericalHarmonics {
  36102. /**
  36103. * Defines whether or not the harmonics have been prescaled for rendering.
  36104. */
  36105. preScaled: boolean;
  36106. /**
  36107. * The l0,0 coefficients of the spherical harmonics
  36108. */
  36109. l00: Vector3;
  36110. /**
  36111. * The l1,-1 coefficients of the spherical harmonics
  36112. */
  36113. l1_1: Vector3;
  36114. /**
  36115. * The l1,0 coefficients of the spherical harmonics
  36116. */
  36117. l10: Vector3;
  36118. /**
  36119. * The l1,1 coefficients of the spherical harmonics
  36120. */
  36121. l11: Vector3;
  36122. /**
  36123. * The l2,-2 coefficients of the spherical harmonics
  36124. */
  36125. l2_2: Vector3;
  36126. /**
  36127. * The l2,-1 coefficients of the spherical harmonics
  36128. */
  36129. l2_1: Vector3;
  36130. /**
  36131. * The l2,0 coefficients of the spherical harmonics
  36132. */
  36133. l20: Vector3;
  36134. /**
  36135. * The l2,1 coefficients of the spherical harmonics
  36136. */
  36137. l21: Vector3;
  36138. /**
  36139. * The l2,2 coefficients of the spherical harmonics
  36140. */
  36141. l22: Vector3;
  36142. /**
  36143. * Adds a light to the spherical harmonics
  36144. * @param direction the direction of the light
  36145. * @param color the color of the light
  36146. * @param deltaSolidAngle the delta solid angle of the light
  36147. */
  36148. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36149. /**
  36150. * Scales the spherical harmonics by the given amount
  36151. * @param scale the amount to scale
  36152. */
  36153. scaleInPlace(scale: number): void;
  36154. /**
  36155. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36156. *
  36157. * ```
  36158. * E_lm = A_l * L_lm
  36159. * ```
  36160. *
  36161. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36162. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36163. * the scaling factors are given in equation 9.
  36164. */
  36165. convertIncidentRadianceToIrradiance(): void;
  36166. /**
  36167. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36168. *
  36169. * ```
  36170. * L = (1/pi) * E * rho
  36171. * ```
  36172. *
  36173. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36174. */
  36175. convertIrradianceToLambertianRadiance(): void;
  36176. /**
  36177. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36178. * required operations at run time.
  36179. *
  36180. * This is simply done by scaling back the SH with Ylm constants parameter.
  36181. * The trigonometric part being applied by the shader at run time.
  36182. */
  36183. preScaleForRendering(): void;
  36184. /**
  36185. * Constructs a spherical harmonics from an array.
  36186. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36187. * @returns the spherical harmonics
  36188. */
  36189. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36190. /**
  36191. * Gets the spherical harmonics from polynomial
  36192. * @param polynomial the spherical polynomial
  36193. * @returns the spherical harmonics
  36194. */
  36195. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36196. }
  36197. /**
  36198. * Class representing spherical polynomial coefficients to the 3rd degree
  36199. */
  36200. export class SphericalPolynomial {
  36201. private _harmonics;
  36202. /**
  36203. * The spherical harmonics used to create the polynomials.
  36204. */
  36205. get preScaledHarmonics(): SphericalHarmonics;
  36206. /**
  36207. * The x coefficients of the spherical polynomial
  36208. */
  36209. x: Vector3;
  36210. /**
  36211. * The y coefficients of the spherical polynomial
  36212. */
  36213. y: Vector3;
  36214. /**
  36215. * The z coefficients of the spherical polynomial
  36216. */
  36217. z: Vector3;
  36218. /**
  36219. * The xx coefficients of the spherical polynomial
  36220. */
  36221. xx: Vector3;
  36222. /**
  36223. * The yy coefficients of the spherical polynomial
  36224. */
  36225. yy: Vector3;
  36226. /**
  36227. * The zz coefficients of the spherical polynomial
  36228. */
  36229. zz: Vector3;
  36230. /**
  36231. * The xy coefficients of the spherical polynomial
  36232. */
  36233. xy: Vector3;
  36234. /**
  36235. * The yz coefficients of the spherical polynomial
  36236. */
  36237. yz: Vector3;
  36238. /**
  36239. * The zx coefficients of the spherical polynomial
  36240. */
  36241. zx: Vector3;
  36242. /**
  36243. * Adds an ambient color to the spherical polynomial
  36244. * @param color the color to add
  36245. */
  36246. addAmbient(color: Color3): void;
  36247. /**
  36248. * Scales the spherical polynomial by the given amount
  36249. * @param scale the amount to scale
  36250. */
  36251. scaleInPlace(scale: number): void;
  36252. /**
  36253. * Gets the spherical polynomial from harmonics
  36254. * @param harmonics the spherical harmonics
  36255. * @returns the spherical polynomial
  36256. */
  36257. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36258. /**
  36259. * Constructs a spherical polynomial from an array.
  36260. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36261. * @returns the spherical polynomial
  36262. */
  36263. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36264. }
  36265. }
  36266. declare module BABYLON {
  36267. /**
  36268. * Defines the source of the internal texture
  36269. */
  36270. export enum InternalTextureSource {
  36271. /**
  36272. * The source of the texture data is unknown
  36273. */
  36274. Unknown = 0,
  36275. /**
  36276. * Texture data comes from an URL
  36277. */
  36278. Url = 1,
  36279. /**
  36280. * Texture data is only used for temporary storage
  36281. */
  36282. Temp = 2,
  36283. /**
  36284. * Texture data comes from raw data (ArrayBuffer)
  36285. */
  36286. Raw = 3,
  36287. /**
  36288. * Texture content is dynamic (video or dynamic texture)
  36289. */
  36290. Dynamic = 4,
  36291. /**
  36292. * Texture content is generated by rendering to it
  36293. */
  36294. RenderTarget = 5,
  36295. /**
  36296. * Texture content is part of a multi render target process
  36297. */
  36298. MultiRenderTarget = 6,
  36299. /**
  36300. * Texture data comes from a cube data file
  36301. */
  36302. Cube = 7,
  36303. /**
  36304. * Texture data comes from a raw cube data
  36305. */
  36306. CubeRaw = 8,
  36307. /**
  36308. * Texture data come from a prefiltered cube data file
  36309. */
  36310. CubePrefiltered = 9,
  36311. /**
  36312. * Texture content is raw 3D data
  36313. */
  36314. Raw3D = 10,
  36315. /**
  36316. * Texture content is raw 2D array data
  36317. */
  36318. Raw2DArray = 11,
  36319. /**
  36320. * Texture content is a depth texture
  36321. */
  36322. Depth = 12,
  36323. /**
  36324. * Texture data comes from a raw cube data encoded with RGBD
  36325. */
  36326. CubeRawRGBD = 13
  36327. }
  36328. /**
  36329. * Class used to store data associated with WebGL texture data for the engine
  36330. * This class should not be used directly
  36331. */
  36332. export class InternalTexture {
  36333. /** @hidden */
  36334. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36335. /**
  36336. * Defines if the texture is ready
  36337. */
  36338. isReady: boolean;
  36339. /**
  36340. * Defines if the texture is a cube texture
  36341. */
  36342. isCube: boolean;
  36343. /**
  36344. * Defines if the texture contains 3D data
  36345. */
  36346. is3D: boolean;
  36347. /**
  36348. * Defines if the texture contains 2D array data
  36349. */
  36350. is2DArray: boolean;
  36351. /**
  36352. * Defines if the texture contains multiview data
  36353. */
  36354. isMultiview: boolean;
  36355. /**
  36356. * Gets the URL used to load this texture
  36357. */
  36358. url: string;
  36359. /**
  36360. * Gets the sampling mode of the texture
  36361. */
  36362. samplingMode: number;
  36363. /**
  36364. * Gets a boolean indicating if the texture needs mipmaps generation
  36365. */
  36366. generateMipMaps: boolean;
  36367. /**
  36368. * Gets the number of samples used by the texture (WebGL2+ only)
  36369. */
  36370. samples: number;
  36371. /**
  36372. * Gets the type of the texture (int, float...)
  36373. */
  36374. type: number;
  36375. /**
  36376. * Gets the format of the texture (RGB, RGBA...)
  36377. */
  36378. format: number;
  36379. /**
  36380. * Observable called when the texture is loaded
  36381. */
  36382. onLoadedObservable: Observable<InternalTexture>;
  36383. /**
  36384. * Gets the width of the texture
  36385. */
  36386. width: number;
  36387. /**
  36388. * Gets the height of the texture
  36389. */
  36390. height: number;
  36391. /**
  36392. * Gets the depth of the texture
  36393. */
  36394. depth: number;
  36395. /**
  36396. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36397. */
  36398. baseWidth: number;
  36399. /**
  36400. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36401. */
  36402. baseHeight: number;
  36403. /**
  36404. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36405. */
  36406. baseDepth: number;
  36407. /**
  36408. * Gets a boolean indicating if the texture is inverted on Y axis
  36409. */
  36410. invertY: boolean;
  36411. /** @hidden */
  36412. _invertVScale: boolean;
  36413. /** @hidden */
  36414. _associatedChannel: number;
  36415. /** @hidden */
  36416. _source: InternalTextureSource;
  36417. /** @hidden */
  36418. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36419. /** @hidden */
  36420. _bufferView: Nullable<ArrayBufferView>;
  36421. /** @hidden */
  36422. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36423. /** @hidden */
  36424. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36425. /** @hidden */
  36426. _size: number;
  36427. /** @hidden */
  36428. _extension: string;
  36429. /** @hidden */
  36430. _files: Nullable<string[]>;
  36431. /** @hidden */
  36432. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36433. /** @hidden */
  36434. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36435. /** @hidden */
  36436. _framebuffer: Nullable<WebGLFramebuffer>;
  36437. /** @hidden */
  36438. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36439. /** @hidden */
  36440. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36441. /** @hidden */
  36442. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36443. /** @hidden */
  36444. _attachments: Nullable<number[]>;
  36445. /** @hidden */
  36446. _textureArray: Nullable<InternalTexture[]>;
  36447. /** @hidden */
  36448. _cachedCoordinatesMode: Nullable<number>;
  36449. /** @hidden */
  36450. _cachedWrapU: Nullable<number>;
  36451. /** @hidden */
  36452. _cachedWrapV: Nullable<number>;
  36453. /** @hidden */
  36454. _cachedWrapR: Nullable<number>;
  36455. /** @hidden */
  36456. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36457. /** @hidden */
  36458. _isDisabled: boolean;
  36459. /** @hidden */
  36460. _compression: Nullable<string>;
  36461. /** @hidden */
  36462. _generateStencilBuffer: boolean;
  36463. /** @hidden */
  36464. _generateDepthBuffer: boolean;
  36465. /** @hidden */
  36466. _comparisonFunction: number;
  36467. /** @hidden */
  36468. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36469. /** @hidden */
  36470. _lodGenerationScale: number;
  36471. /** @hidden */
  36472. _lodGenerationOffset: number;
  36473. /** @hidden */
  36474. _depthStencilTexture: Nullable<InternalTexture>;
  36475. /** @hidden */
  36476. _colorTextureArray: Nullable<WebGLTexture>;
  36477. /** @hidden */
  36478. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36479. /** @hidden */
  36480. _lodTextureHigh: Nullable<BaseTexture>;
  36481. /** @hidden */
  36482. _lodTextureMid: Nullable<BaseTexture>;
  36483. /** @hidden */
  36484. _lodTextureLow: Nullable<BaseTexture>;
  36485. /** @hidden */
  36486. _isRGBD: boolean;
  36487. /** @hidden */
  36488. _linearSpecularLOD: boolean;
  36489. /** @hidden */
  36490. _irradianceTexture: Nullable<BaseTexture>;
  36491. /** @hidden */
  36492. _webGLTexture: Nullable<WebGLTexture>;
  36493. /** @hidden */
  36494. _references: number;
  36495. private _engine;
  36496. /**
  36497. * Gets the Engine the texture belongs to.
  36498. * @returns The babylon engine
  36499. */
  36500. getEngine(): ThinEngine;
  36501. /**
  36502. * Gets the data source type of the texture
  36503. */
  36504. get source(): InternalTextureSource;
  36505. /**
  36506. * Creates a new InternalTexture
  36507. * @param engine defines the engine to use
  36508. * @param source defines the type of data that will be used
  36509. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36510. */
  36511. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36512. /**
  36513. * Increments the number of references (ie. the number of Texture that point to it)
  36514. */
  36515. incrementReferences(): void;
  36516. /**
  36517. * Change the size of the texture (not the size of the content)
  36518. * @param width defines the new width
  36519. * @param height defines the new height
  36520. * @param depth defines the new depth (1 by default)
  36521. */
  36522. updateSize(width: int, height: int, depth?: int): void;
  36523. /** @hidden */
  36524. _rebuild(): void;
  36525. /** @hidden */
  36526. _swapAndDie(target: InternalTexture): void;
  36527. /**
  36528. * Dispose the current allocated resources
  36529. */
  36530. dispose(): void;
  36531. }
  36532. }
  36533. declare module BABYLON {
  36534. /**
  36535. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36537. */
  36538. export class Analyser {
  36539. /**
  36540. * Gets or sets the smoothing
  36541. * @ignorenaming
  36542. */
  36543. SMOOTHING: number;
  36544. /**
  36545. * Gets or sets the FFT table size
  36546. * @ignorenaming
  36547. */
  36548. FFT_SIZE: number;
  36549. /**
  36550. * Gets or sets the bar graph amplitude
  36551. * @ignorenaming
  36552. */
  36553. BARGRAPHAMPLITUDE: number;
  36554. /**
  36555. * Gets or sets the position of the debug canvas
  36556. * @ignorenaming
  36557. */
  36558. DEBUGCANVASPOS: {
  36559. x: number;
  36560. y: number;
  36561. };
  36562. /**
  36563. * Gets or sets the debug canvas size
  36564. * @ignorenaming
  36565. */
  36566. DEBUGCANVASSIZE: {
  36567. width: number;
  36568. height: number;
  36569. };
  36570. private _byteFreqs;
  36571. private _byteTime;
  36572. private _floatFreqs;
  36573. private _webAudioAnalyser;
  36574. private _debugCanvas;
  36575. private _debugCanvasContext;
  36576. private _scene;
  36577. private _registerFunc;
  36578. private _audioEngine;
  36579. /**
  36580. * Creates a new analyser
  36581. * @param scene defines hosting scene
  36582. */
  36583. constructor(scene: Scene);
  36584. /**
  36585. * Get the number of data values you will have to play with for the visualization
  36586. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36587. * @returns a number
  36588. */
  36589. getFrequencyBinCount(): number;
  36590. /**
  36591. * Gets the current frequency data as a byte array
  36592. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36593. * @returns a Uint8Array
  36594. */
  36595. getByteFrequencyData(): Uint8Array;
  36596. /**
  36597. * Gets the current waveform as a byte array
  36598. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36599. * @returns a Uint8Array
  36600. */
  36601. getByteTimeDomainData(): Uint8Array;
  36602. /**
  36603. * Gets the current frequency data as a float array
  36604. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36605. * @returns a Float32Array
  36606. */
  36607. getFloatFrequencyData(): Float32Array;
  36608. /**
  36609. * Renders the debug canvas
  36610. */
  36611. drawDebugCanvas(): void;
  36612. /**
  36613. * Stops rendering the debug canvas and removes it
  36614. */
  36615. stopDebugCanvas(): void;
  36616. /**
  36617. * Connects two audio nodes
  36618. * @param inputAudioNode defines first node to connect
  36619. * @param outputAudioNode defines second node to connect
  36620. */
  36621. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36622. /**
  36623. * Releases all associated resources
  36624. */
  36625. dispose(): void;
  36626. }
  36627. }
  36628. declare module BABYLON {
  36629. /**
  36630. * This represents an audio engine and it is responsible
  36631. * to play, synchronize and analyse sounds throughout the application.
  36632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36633. */
  36634. export interface IAudioEngine extends IDisposable {
  36635. /**
  36636. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36637. */
  36638. readonly canUseWebAudio: boolean;
  36639. /**
  36640. * Gets the current AudioContext if available.
  36641. */
  36642. readonly audioContext: Nullable<AudioContext>;
  36643. /**
  36644. * The master gain node defines the global audio volume of your audio engine.
  36645. */
  36646. readonly masterGain: GainNode;
  36647. /**
  36648. * Gets whether or not mp3 are supported by your browser.
  36649. */
  36650. readonly isMP3supported: boolean;
  36651. /**
  36652. * Gets whether or not ogg are supported by your browser.
  36653. */
  36654. readonly isOGGsupported: boolean;
  36655. /**
  36656. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36657. * @ignoreNaming
  36658. */
  36659. WarnedWebAudioUnsupported: boolean;
  36660. /**
  36661. * Defines if the audio engine relies on a custom unlocked button.
  36662. * In this case, the embedded button will not be displayed.
  36663. */
  36664. useCustomUnlockedButton: boolean;
  36665. /**
  36666. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36667. */
  36668. readonly unlocked: boolean;
  36669. /**
  36670. * Event raised when audio has been unlocked on the browser.
  36671. */
  36672. onAudioUnlockedObservable: Observable<AudioEngine>;
  36673. /**
  36674. * Event raised when audio has been locked on the browser.
  36675. */
  36676. onAudioLockedObservable: Observable<AudioEngine>;
  36677. /**
  36678. * Flags the audio engine in Locked state.
  36679. * This happens due to new browser policies preventing audio to autoplay.
  36680. */
  36681. lock(): void;
  36682. /**
  36683. * Unlocks the audio engine once a user action has been done on the dom.
  36684. * This is helpful to resume play once browser policies have been satisfied.
  36685. */
  36686. unlock(): void;
  36687. /**
  36688. * Gets the global volume sets on the master gain.
  36689. * @returns the global volume if set or -1 otherwise
  36690. */
  36691. getGlobalVolume(): number;
  36692. /**
  36693. * Sets the global volume of your experience (sets on the master gain).
  36694. * @param newVolume Defines the new global volume of the application
  36695. */
  36696. setGlobalVolume(newVolume: number): void;
  36697. /**
  36698. * Connect the audio engine to an audio analyser allowing some amazing
  36699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36700. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36701. * @param analyser The analyser to connect to the engine
  36702. */
  36703. connectToAnalyser(analyser: Analyser): void;
  36704. }
  36705. /**
  36706. * This represents the default audio engine used in babylon.
  36707. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36709. */
  36710. export class AudioEngine implements IAudioEngine {
  36711. private _audioContext;
  36712. private _audioContextInitialized;
  36713. private _muteButton;
  36714. private _hostElement;
  36715. /**
  36716. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36717. */
  36718. canUseWebAudio: boolean;
  36719. /**
  36720. * The master gain node defines the global audio volume of your audio engine.
  36721. */
  36722. masterGain: GainNode;
  36723. /**
  36724. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36725. * @ignoreNaming
  36726. */
  36727. WarnedWebAudioUnsupported: boolean;
  36728. /**
  36729. * Gets whether or not mp3 are supported by your browser.
  36730. */
  36731. isMP3supported: boolean;
  36732. /**
  36733. * Gets whether or not ogg are supported by your browser.
  36734. */
  36735. isOGGsupported: boolean;
  36736. /**
  36737. * Gets whether audio has been unlocked on the device.
  36738. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36739. * a user interaction has happened.
  36740. */
  36741. unlocked: boolean;
  36742. /**
  36743. * Defines if the audio engine relies on a custom unlocked button.
  36744. * In this case, the embedded button will not be displayed.
  36745. */
  36746. useCustomUnlockedButton: boolean;
  36747. /**
  36748. * Event raised when audio has been unlocked on the browser.
  36749. */
  36750. onAudioUnlockedObservable: Observable<AudioEngine>;
  36751. /**
  36752. * Event raised when audio has been locked on the browser.
  36753. */
  36754. onAudioLockedObservable: Observable<AudioEngine>;
  36755. /**
  36756. * Gets the current AudioContext if available.
  36757. */
  36758. get audioContext(): Nullable<AudioContext>;
  36759. private _connectedAnalyser;
  36760. /**
  36761. * Instantiates a new audio engine.
  36762. *
  36763. * There should be only one per page as some browsers restrict the number
  36764. * of audio contexts you can create.
  36765. * @param hostElement defines the host element where to display the mute icon if necessary
  36766. */
  36767. constructor(hostElement?: Nullable<HTMLElement>);
  36768. /**
  36769. * Flags the audio engine in Locked state.
  36770. * This happens due to new browser policies preventing audio to autoplay.
  36771. */
  36772. lock(): void;
  36773. /**
  36774. * Unlocks the audio engine once a user action has been done on the dom.
  36775. * This is helpful to resume play once browser policies have been satisfied.
  36776. */
  36777. unlock(): void;
  36778. private _resumeAudioContext;
  36779. private _initializeAudioContext;
  36780. private _tryToRun;
  36781. private _triggerRunningState;
  36782. private _triggerSuspendedState;
  36783. private _displayMuteButton;
  36784. private _moveButtonToTopLeft;
  36785. private _onResize;
  36786. private _hideMuteButton;
  36787. /**
  36788. * Destroy and release the resources associated with the audio ccontext.
  36789. */
  36790. dispose(): void;
  36791. /**
  36792. * Gets the global volume sets on the master gain.
  36793. * @returns the global volume if set or -1 otherwise
  36794. */
  36795. getGlobalVolume(): number;
  36796. /**
  36797. * Sets the global volume of your experience (sets on the master gain).
  36798. * @param newVolume Defines the new global volume of the application
  36799. */
  36800. setGlobalVolume(newVolume: number): void;
  36801. /**
  36802. * Connect the audio engine to an audio analyser allowing some amazing
  36803. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36804. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36805. * @param analyser The analyser to connect to the engine
  36806. */
  36807. connectToAnalyser(analyser: Analyser): void;
  36808. }
  36809. }
  36810. declare module BABYLON {
  36811. /**
  36812. * Interface used to present a loading screen while loading a scene
  36813. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36814. */
  36815. export interface ILoadingScreen {
  36816. /**
  36817. * Function called to display the loading screen
  36818. */
  36819. displayLoadingUI: () => void;
  36820. /**
  36821. * Function called to hide the loading screen
  36822. */
  36823. hideLoadingUI: () => void;
  36824. /**
  36825. * Gets or sets the color to use for the background
  36826. */
  36827. loadingUIBackgroundColor: string;
  36828. /**
  36829. * Gets or sets the text to display while loading
  36830. */
  36831. loadingUIText: string;
  36832. }
  36833. /**
  36834. * Class used for the default loading screen
  36835. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36836. */
  36837. export class DefaultLoadingScreen implements ILoadingScreen {
  36838. private _renderingCanvas;
  36839. private _loadingText;
  36840. private _loadingDivBackgroundColor;
  36841. private _loadingDiv;
  36842. private _loadingTextDiv;
  36843. /** Gets or sets the logo url to use for the default loading screen */
  36844. static DefaultLogoUrl: string;
  36845. /** Gets or sets the spinner url to use for the default loading screen */
  36846. static DefaultSpinnerUrl: string;
  36847. /**
  36848. * Creates a new default loading screen
  36849. * @param _renderingCanvas defines the canvas used to render the scene
  36850. * @param _loadingText defines the default text to display
  36851. * @param _loadingDivBackgroundColor defines the default background color
  36852. */
  36853. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36854. /**
  36855. * Function called to display the loading screen
  36856. */
  36857. displayLoadingUI(): void;
  36858. /**
  36859. * Function called to hide the loading screen
  36860. */
  36861. hideLoadingUI(): void;
  36862. /**
  36863. * Gets or sets the text to display while loading
  36864. */
  36865. set loadingUIText(text: string);
  36866. get loadingUIText(): string;
  36867. /**
  36868. * Gets or sets the color to use for the background
  36869. */
  36870. get loadingUIBackgroundColor(): string;
  36871. set loadingUIBackgroundColor(color: string);
  36872. private _resizeLoadingUI;
  36873. }
  36874. }
  36875. declare module BABYLON {
  36876. /**
  36877. * Interface for any object that can request an animation frame
  36878. */
  36879. export interface ICustomAnimationFrameRequester {
  36880. /**
  36881. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36882. */
  36883. renderFunction?: Function;
  36884. /**
  36885. * Called to request the next frame to render to
  36886. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36887. */
  36888. requestAnimationFrame: Function;
  36889. /**
  36890. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36891. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36892. */
  36893. requestID?: number;
  36894. }
  36895. }
  36896. declare module BABYLON {
  36897. /**
  36898. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36899. */
  36900. export class PerformanceMonitor {
  36901. private _enabled;
  36902. private _rollingFrameTime;
  36903. private _lastFrameTimeMs;
  36904. /**
  36905. * constructor
  36906. * @param frameSampleSize The number of samples required to saturate the sliding window
  36907. */
  36908. constructor(frameSampleSize?: number);
  36909. /**
  36910. * Samples current frame
  36911. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36912. */
  36913. sampleFrame(timeMs?: number): void;
  36914. /**
  36915. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36916. */
  36917. get averageFrameTime(): number;
  36918. /**
  36919. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36920. */
  36921. get averageFrameTimeVariance(): number;
  36922. /**
  36923. * Returns the frame time of the most recent frame
  36924. */
  36925. get instantaneousFrameTime(): number;
  36926. /**
  36927. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36928. */
  36929. get averageFPS(): number;
  36930. /**
  36931. * Returns the average framerate in frames per second using the most recent frame time
  36932. */
  36933. get instantaneousFPS(): number;
  36934. /**
  36935. * Returns true if enough samples have been taken to completely fill the sliding window
  36936. */
  36937. get isSaturated(): boolean;
  36938. /**
  36939. * Enables contributions to the sliding window sample set
  36940. */
  36941. enable(): void;
  36942. /**
  36943. * Disables contributions to the sliding window sample set
  36944. * Samples will not be interpolated over the disabled period
  36945. */
  36946. disable(): void;
  36947. /**
  36948. * Returns true if sampling is enabled
  36949. */
  36950. get isEnabled(): boolean;
  36951. /**
  36952. * Resets performance monitor
  36953. */
  36954. reset(): void;
  36955. }
  36956. /**
  36957. * RollingAverage
  36958. *
  36959. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36960. */
  36961. export class RollingAverage {
  36962. /**
  36963. * Current average
  36964. */
  36965. average: number;
  36966. /**
  36967. * Current variance
  36968. */
  36969. variance: number;
  36970. protected _samples: Array<number>;
  36971. protected _sampleCount: number;
  36972. protected _pos: number;
  36973. protected _m2: number;
  36974. /**
  36975. * constructor
  36976. * @param length The number of samples required to saturate the sliding window
  36977. */
  36978. constructor(length: number);
  36979. /**
  36980. * Adds a sample to the sample set
  36981. * @param v The sample value
  36982. */
  36983. add(v: number): void;
  36984. /**
  36985. * Returns previously added values or null if outside of history or outside the sliding window domain
  36986. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36987. * @return Value previously recorded with add() or null if outside of range
  36988. */
  36989. history(i: number): number;
  36990. /**
  36991. * Returns true if enough samples have been taken to completely fill the sliding window
  36992. * @return true if sample-set saturated
  36993. */
  36994. isSaturated(): boolean;
  36995. /**
  36996. * Resets the rolling average (equivalent to 0 samples taken so far)
  36997. */
  36998. reset(): void;
  36999. /**
  37000. * Wraps a value around the sample range boundaries
  37001. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37002. * @return Wrapped position in sample range
  37003. */
  37004. protected _wrapPosition(i: number): number;
  37005. }
  37006. }
  37007. declare module BABYLON {
  37008. /**
  37009. * This class is used to track a performance counter which is number based.
  37010. * The user has access to many properties which give statistics of different nature.
  37011. *
  37012. * The implementer can track two kinds of Performance Counter: time and count.
  37013. * 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.
  37014. * 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.
  37015. */
  37016. export class PerfCounter {
  37017. /**
  37018. * Gets or sets a global boolean to turn on and off all the counters
  37019. */
  37020. static Enabled: boolean;
  37021. /**
  37022. * Returns the smallest value ever
  37023. */
  37024. get min(): number;
  37025. /**
  37026. * Returns the biggest value ever
  37027. */
  37028. get max(): number;
  37029. /**
  37030. * Returns the average value since the performance counter is running
  37031. */
  37032. get average(): number;
  37033. /**
  37034. * Returns the average value of the last second the counter was monitored
  37035. */
  37036. get lastSecAverage(): number;
  37037. /**
  37038. * Returns the current value
  37039. */
  37040. get current(): number;
  37041. /**
  37042. * Gets the accumulated total
  37043. */
  37044. get total(): number;
  37045. /**
  37046. * Gets the total value count
  37047. */
  37048. get count(): number;
  37049. /**
  37050. * Creates a new counter
  37051. */
  37052. constructor();
  37053. /**
  37054. * Call this method to start monitoring a new frame.
  37055. * 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.
  37056. */
  37057. fetchNewFrame(): void;
  37058. /**
  37059. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37060. * @param newCount the count value to add to the monitored count
  37061. * @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.
  37062. */
  37063. addCount(newCount: number, fetchResult: boolean): void;
  37064. /**
  37065. * Start monitoring this performance counter
  37066. */
  37067. beginMonitoring(): void;
  37068. /**
  37069. * Compute the time lapsed since the previous beginMonitoring() call.
  37070. * @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
  37071. */
  37072. endMonitoring(newFrame?: boolean): void;
  37073. private _fetchResult;
  37074. private _startMonitoringTime;
  37075. private _min;
  37076. private _max;
  37077. private _average;
  37078. private _current;
  37079. private _totalValueCount;
  37080. private _totalAccumulated;
  37081. private _lastSecAverage;
  37082. private _lastSecAccumulated;
  37083. private _lastSecTime;
  37084. private _lastSecValueCount;
  37085. }
  37086. }
  37087. declare module BABYLON {
  37088. interface ThinEngine {
  37089. /**
  37090. * Sets alpha constants used by some alpha blending modes
  37091. * @param r defines the red component
  37092. * @param g defines the green component
  37093. * @param b defines the blue component
  37094. * @param a defines the alpha component
  37095. */
  37096. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37097. /**
  37098. * Sets the current alpha mode
  37099. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37100. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37101. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37102. */
  37103. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37104. /**
  37105. * Gets the current alpha mode
  37106. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37107. * @returns the current alpha mode
  37108. */
  37109. getAlphaMode(): number;
  37110. /**
  37111. * Sets the current alpha equation
  37112. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37113. */
  37114. setAlphaEquation(equation: number): void;
  37115. /**
  37116. * Gets the current alpha equation.
  37117. * @returns the current alpha equation
  37118. */
  37119. getAlphaEquation(): number;
  37120. }
  37121. }
  37122. declare module BABYLON {
  37123. interface ThinEngine {
  37124. /** @hidden */
  37125. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37126. }
  37127. }
  37128. declare module BABYLON {
  37129. /**
  37130. * Defines the interface used by display changed events
  37131. */
  37132. export interface IDisplayChangedEventArgs {
  37133. /** Gets the vrDisplay object (if any) */
  37134. vrDisplay: Nullable<any>;
  37135. /** Gets a boolean indicating if webVR is supported */
  37136. vrSupported: boolean;
  37137. }
  37138. /**
  37139. * Defines the interface used by objects containing a viewport (like a camera)
  37140. */
  37141. interface IViewportOwnerLike {
  37142. /**
  37143. * Gets or sets the viewport
  37144. */
  37145. viewport: IViewportLike;
  37146. }
  37147. /**
  37148. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37149. */
  37150. export class Engine extends ThinEngine {
  37151. /** Defines that alpha blending is disabled */
  37152. static readonly ALPHA_DISABLE: number;
  37153. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37154. static readonly ALPHA_ADD: number;
  37155. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37156. static readonly ALPHA_COMBINE: number;
  37157. /** Defines that alpha blending to DEST - SRC * DEST */
  37158. static readonly ALPHA_SUBTRACT: number;
  37159. /** Defines that alpha blending to SRC * DEST */
  37160. static readonly ALPHA_MULTIPLY: number;
  37161. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37162. static readonly ALPHA_MAXIMIZED: number;
  37163. /** Defines that alpha blending to SRC + DEST */
  37164. static readonly ALPHA_ONEONE: number;
  37165. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37166. static readonly ALPHA_PREMULTIPLIED: number;
  37167. /**
  37168. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37169. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37170. */
  37171. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37172. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37173. static readonly ALPHA_INTERPOLATE: number;
  37174. /**
  37175. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37176. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37177. */
  37178. static readonly ALPHA_SCREENMODE: number;
  37179. /** Defines that the ressource is not delayed*/
  37180. static readonly DELAYLOADSTATE_NONE: number;
  37181. /** Defines that the ressource was successfully delay loaded */
  37182. static readonly DELAYLOADSTATE_LOADED: number;
  37183. /** Defines that the ressource is currently delay loading */
  37184. static readonly DELAYLOADSTATE_LOADING: number;
  37185. /** Defines that the ressource is delayed and has not started loading */
  37186. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37187. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37188. static readonly NEVER: number;
  37189. /** 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 */
  37190. static readonly ALWAYS: number;
  37191. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37192. static readonly LESS: number;
  37193. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37194. static readonly EQUAL: number;
  37195. /** 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 */
  37196. static readonly LEQUAL: number;
  37197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37198. static readonly GREATER: number;
  37199. /** 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 */
  37200. static readonly GEQUAL: number;
  37201. /** 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 */
  37202. static readonly NOTEQUAL: number;
  37203. /** Passed to stencilOperation to specify that stencil value must be kept */
  37204. static readonly KEEP: number;
  37205. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37206. static readonly REPLACE: number;
  37207. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37208. static readonly INCR: number;
  37209. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37210. static readonly DECR: number;
  37211. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37212. static readonly INVERT: number;
  37213. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37214. static readonly INCR_WRAP: number;
  37215. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37216. static readonly DECR_WRAP: number;
  37217. /** Texture is not repeating outside of 0..1 UVs */
  37218. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37219. /** Texture is repeating outside of 0..1 UVs */
  37220. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37221. /** Texture is repeating and mirrored */
  37222. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37223. /** ALPHA */
  37224. static readonly TEXTUREFORMAT_ALPHA: number;
  37225. /** LUMINANCE */
  37226. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37227. /** LUMINANCE_ALPHA */
  37228. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37229. /** RGB */
  37230. static readonly TEXTUREFORMAT_RGB: number;
  37231. /** RGBA */
  37232. static readonly TEXTUREFORMAT_RGBA: number;
  37233. /** RED */
  37234. static readonly TEXTUREFORMAT_RED: number;
  37235. /** RED (2nd reference) */
  37236. static readonly TEXTUREFORMAT_R: number;
  37237. /** RG */
  37238. static readonly TEXTUREFORMAT_RG: number;
  37239. /** RED_INTEGER */
  37240. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37241. /** RED_INTEGER (2nd reference) */
  37242. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37243. /** RG_INTEGER */
  37244. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37245. /** RGB_INTEGER */
  37246. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37247. /** RGBA_INTEGER */
  37248. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37249. /** UNSIGNED_BYTE */
  37250. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37251. /** UNSIGNED_BYTE (2nd reference) */
  37252. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37253. /** FLOAT */
  37254. static readonly TEXTURETYPE_FLOAT: number;
  37255. /** HALF_FLOAT */
  37256. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37257. /** BYTE */
  37258. static readonly TEXTURETYPE_BYTE: number;
  37259. /** SHORT */
  37260. static readonly TEXTURETYPE_SHORT: number;
  37261. /** UNSIGNED_SHORT */
  37262. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37263. /** INT */
  37264. static readonly TEXTURETYPE_INT: number;
  37265. /** UNSIGNED_INT */
  37266. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37267. /** UNSIGNED_SHORT_4_4_4_4 */
  37268. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37269. /** UNSIGNED_SHORT_5_5_5_1 */
  37270. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37271. /** UNSIGNED_SHORT_5_6_5 */
  37272. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37273. /** UNSIGNED_INT_2_10_10_10_REV */
  37274. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37275. /** UNSIGNED_INT_24_8 */
  37276. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37277. /** UNSIGNED_INT_10F_11F_11F_REV */
  37278. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37279. /** UNSIGNED_INT_5_9_9_9_REV */
  37280. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37281. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37282. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37283. /** nearest is mag = nearest and min = nearest and mip = linear */
  37284. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37285. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37286. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37287. /** Trilinear is mag = linear and min = linear and mip = linear */
  37288. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37289. /** nearest is mag = nearest and min = nearest and mip = linear */
  37290. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37291. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37292. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37293. /** Trilinear is mag = linear and min = linear and mip = linear */
  37294. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37295. /** mag = nearest and min = nearest and mip = nearest */
  37296. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37297. /** mag = nearest and min = linear and mip = nearest */
  37298. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37299. /** mag = nearest and min = linear and mip = linear */
  37300. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37301. /** mag = nearest and min = linear and mip = none */
  37302. static readonly TEXTURE_NEAREST_LINEAR: number;
  37303. /** mag = nearest and min = nearest and mip = none */
  37304. static readonly TEXTURE_NEAREST_NEAREST: number;
  37305. /** mag = linear and min = nearest and mip = nearest */
  37306. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37307. /** mag = linear and min = nearest and mip = linear */
  37308. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37309. /** mag = linear and min = linear and mip = none */
  37310. static readonly TEXTURE_LINEAR_LINEAR: number;
  37311. /** mag = linear and min = nearest and mip = none */
  37312. static readonly TEXTURE_LINEAR_NEAREST: number;
  37313. /** Explicit coordinates mode */
  37314. static readonly TEXTURE_EXPLICIT_MODE: number;
  37315. /** Spherical coordinates mode */
  37316. static readonly TEXTURE_SPHERICAL_MODE: number;
  37317. /** Planar coordinates mode */
  37318. static readonly TEXTURE_PLANAR_MODE: number;
  37319. /** Cubic coordinates mode */
  37320. static readonly TEXTURE_CUBIC_MODE: number;
  37321. /** Projection coordinates mode */
  37322. static readonly TEXTURE_PROJECTION_MODE: number;
  37323. /** Skybox coordinates mode */
  37324. static readonly TEXTURE_SKYBOX_MODE: number;
  37325. /** Inverse Cubic coordinates mode */
  37326. static readonly TEXTURE_INVCUBIC_MODE: number;
  37327. /** Equirectangular coordinates mode */
  37328. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37329. /** Equirectangular Fixed coordinates mode */
  37330. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37331. /** Equirectangular Fixed Mirrored coordinates mode */
  37332. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37333. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37334. static readonly SCALEMODE_FLOOR: number;
  37335. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37336. static readonly SCALEMODE_NEAREST: number;
  37337. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37338. static readonly SCALEMODE_CEILING: number;
  37339. /**
  37340. * Returns the current npm package of the sdk
  37341. */
  37342. static get NpmPackage(): string;
  37343. /**
  37344. * Returns the current version of the framework
  37345. */
  37346. static get Version(): string;
  37347. /** Gets the list of created engines */
  37348. static get Instances(): Engine[];
  37349. /**
  37350. * Gets the latest created engine
  37351. */
  37352. static get LastCreatedEngine(): Nullable<Engine>;
  37353. /**
  37354. * Gets the latest created scene
  37355. */
  37356. static get LastCreatedScene(): Nullable<Scene>;
  37357. /**
  37358. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37359. * @param flag defines which part of the materials must be marked as dirty
  37360. * @param predicate defines a predicate used to filter which materials should be affected
  37361. */
  37362. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37363. /**
  37364. * Method called to create the default loading screen.
  37365. * This can be overriden in your own app.
  37366. * @param canvas The rendering canvas element
  37367. * @returns The loading screen
  37368. */
  37369. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37370. /**
  37371. * Method called to create the default rescale post process on each engine.
  37372. */
  37373. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37374. /**
  37375. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37376. **/
  37377. enableOfflineSupport: boolean;
  37378. /**
  37379. * 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)
  37380. **/
  37381. disableManifestCheck: boolean;
  37382. /**
  37383. * Gets the list of created scenes
  37384. */
  37385. scenes: Scene[];
  37386. /**
  37387. * Event raised when a new scene is created
  37388. */
  37389. onNewSceneAddedObservable: Observable<Scene>;
  37390. /**
  37391. * Gets the list of created postprocesses
  37392. */
  37393. postProcesses: PostProcess[];
  37394. /**
  37395. * Gets a boolean indicating if the pointer is currently locked
  37396. */
  37397. isPointerLock: boolean;
  37398. /**
  37399. * Observable event triggered each time the rendering canvas is resized
  37400. */
  37401. onResizeObservable: Observable<Engine>;
  37402. /**
  37403. * Observable event triggered each time the canvas loses focus
  37404. */
  37405. onCanvasBlurObservable: Observable<Engine>;
  37406. /**
  37407. * Observable event triggered each time the canvas gains focus
  37408. */
  37409. onCanvasFocusObservable: Observable<Engine>;
  37410. /**
  37411. * Observable event triggered each time the canvas receives pointerout event
  37412. */
  37413. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37414. /**
  37415. * Observable raised when the engine begins a new frame
  37416. */
  37417. onBeginFrameObservable: Observable<Engine>;
  37418. /**
  37419. * If set, will be used to request the next animation frame for the render loop
  37420. */
  37421. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37422. /**
  37423. * Observable raised when the engine ends the current frame
  37424. */
  37425. onEndFrameObservable: Observable<Engine>;
  37426. /**
  37427. * Observable raised when the engine is about to compile a shader
  37428. */
  37429. onBeforeShaderCompilationObservable: Observable<Engine>;
  37430. /**
  37431. * Observable raised when the engine has jsut compiled a shader
  37432. */
  37433. onAfterShaderCompilationObservable: Observable<Engine>;
  37434. /**
  37435. * Gets the audio engine
  37436. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37437. * @ignorenaming
  37438. */
  37439. static audioEngine: IAudioEngine;
  37440. /**
  37441. * Default AudioEngine factory responsible of creating the Audio Engine.
  37442. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37443. */
  37444. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37445. /**
  37446. * Default offline support factory responsible of creating a tool used to store data locally.
  37447. * By default, this will create a Database object if the workload has been embedded.
  37448. */
  37449. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37450. private _loadingScreen;
  37451. private _pointerLockRequested;
  37452. private _rescalePostProcess;
  37453. private _deterministicLockstep;
  37454. private _lockstepMaxSteps;
  37455. private _timeStep;
  37456. protected get _supportsHardwareTextureRescaling(): boolean;
  37457. private _fps;
  37458. private _deltaTime;
  37459. /** @hidden */
  37460. _drawCalls: PerfCounter;
  37461. /** 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 */
  37462. canvasTabIndex: number;
  37463. /**
  37464. * Turn this value on if you want to pause FPS computation when in background
  37465. */
  37466. disablePerformanceMonitorInBackground: boolean;
  37467. private _performanceMonitor;
  37468. /**
  37469. * Gets the performance monitor attached to this engine
  37470. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37471. */
  37472. get performanceMonitor(): PerformanceMonitor;
  37473. private _onFocus;
  37474. private _onBlur;
  37475. private _onCanvasPointerOut;
  37476. private _onCanvasBlur;
  37477. private _onCanvasFocus;
  37478. private _onFullscreenChange;
  37479. private _onPointerLockChange;
  37480. /**
  37481. * Gets the HTML element used to attach event listeners
  37482. * @returns a HTML element
  37483. */
  37484. getInputElement(): Nullable<HTMLElement>;
  37485. /**
  37486. * Creates a new engine
  37487. * @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
  37488. * @param antialias defines enable antialiasing (default: false)
  37489. * @param options defines further options to be sent to the getContext() function
  37490. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37491. */
  37492. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37493. /**
  37494. * Gets current aspect ratio
  37495. * @param viewportOwner defines the camera to use to get the aspect ratio
  37496. * @param useScreen defines if screen size must be used (or the current render target if any)
  37497. * @returns a number defining the aspect ratio
  37498. */
  37499. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37500. /**
  37501. * Gets current screen aspect ratio
  37502. * @returns a number defining the aspect ratio
  37503. */
  37504. getScreenAspectRatio(): number;
  37505. /**
  37506. * Gets the client rect of the HTML canvas attached with the current webGL context
  37507. * @returns a client rectanglee
  37508. */
  37509. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37510. /**
  37511. * Gets the client rect of the HTML element used for events
  37512. * @returns a client rectanglee
  37513. */
  37514. getInputElementClientRect(): Nullable<ClientRect>;
  37515. /**
  37516. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37517. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37518. * @returns true if engine is in deterministic lock step mode
  37519. */
  37520. isDeterministicLockStep(): boolean;
  37521. /**
  37522. * Gets the max steps when engine is running in deterministic lock step
  37523. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37524. * @returns the max steps
  37525. */
  37526. getLockstepMaxSteps(): number;
  37527. /**
  37528. * Returns the time in ms between steps when using deterministic lock step.
  37529. * @returns time step in (ms)
  37530. */
  37531. getTimeStep(): number;
  37532. /**
  37533. * Force the mipmap generation for the given render target texture
  37534. * @param texture defines the render target texture to use
  37535. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37536. */
  37537. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37538. /** States */
  37539. /**
  37540. * Set various states to the webGL context
  37541. * @param culling defines backface culling state
  37542. * @param zOffset defines the value to apply to zOffset (0 by default)
  37543. * @param force defines if states must be applied even if cache is up to date
  37544. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37545. */
  37546. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37547. /**
  37548. * Set the z offset to apply to current rendering
  37549. * @param value defines the offset to apply
  37550. */
  37551. setZOffset(value: number): void;
  37552. /**
  37553. * Gets the current value of the zOffset
  37554. * @returns the current zOffset state
  37555. */
  37556. getZOffset(): number;
  37557. /**
  37558. * Enable or disable depth buffering
  37559. * @param enable defines the state to set
  37560. */
  37561. setDepthBuffer(enable: boolean): void;
  37562. /**
  37563. * Gets a boolean indicating if depth writing is enabled
  37564. * @returns the current depth writing state
  37565. */
  37566. getDepthWrite(): boolean;
  37567. /**
  37568. * Enable or disable depth writing
  37569. * @param enable defines the state to set
  37570. */
  37571. setDepthWrite(enable: boolean): void;
  37572. /**
  37573. * Gets a boolean indicating if stencil buffer is enabled
  37574. * @returns the current stencil buffer state
  37575. */
  37576. getStencilBuffer(): boolean;
  37577. /**
  37578. * Enable or disable the stencil buffer
  37579. * @param enable defines if the stencil buffer must be enabled or disabled
  37580. */
  37581. setStencilBuffer(enable: boolean): void;
  37582. /**
  37583. * Gets the current stencil mask
  37584. * @returns a number defining the new stencil mask to use
  37585. */
  37586. getStencilMask(): number;
  37587. /**
  37588. * Sets the current stencil mask
  37589. * @param mask defines the new stencil mask to use
  37590. */
  37591. setStencilMask(mask: number): void;
  37592. /**
  37593. * Gets the current stencil function
  37594. * @returns a number defining the stencil function to use
  37595. */
  37596. getStencilFunction(): number;
  37597. /**
  37598. * Gets the current stencil reference value
  37599. * @returns a number defining the stencil reference value to use
  37600. */
  37601. getStencilFunctionReference(): number;
  37602. /**
  37603. * Gets the current stencil mask
  37604. * @returns a number defining the stencil mask to use
  37605. */
  37606. getStencilFunctionMask(): number;
  37607. /**
  37608. * Sets the current stencil function
  37609. * @param stencilFunc defines the new stencil function to use
  37610. */
  37611. setStencilFunction(stencilFunc: number): void;
  37612. /**
  37613. * Sets the current stencil reference
  37614. * @param reference defines the new stencil reference to use
  37615. */
  37616. setStencilFunctionReference(reference: number): void;
  37617. /**
  37618. * Sets the current stencil mask
  37619. * @param mask defines the new stencil mask to use
  37620. */
  37621. setStencilFunctionMask(mask: number): void;
  37622. /**
  37623. * Gets the current stencil operation when stencil fails
  37624. * @returns a number defining stencil operation to use when stencil fails
  37625. */
  37626. getStencilOperationFail(): number;
  37627. /**
  37628. * Gets the current stencil operation when depth fails
  37629. * @returns a number defining stencil operation to use when depth fails
  37630. */
  37631. getStencilOperationDepthFail(): number;
  37632. /**
  37633. * Gets the current stencil operation when stencil passes
  37634. * @returns a number defining stencil operation to use when stencil passes
  37635. */
  37636. getStencilOperationPass(): number;
  37637. /**
  37638. * Sets the stencil operation to use when stencil fails
  37639. * @param operation defines the stencil operation to use when stencil fails
  37640. */
  37641. setStencilOperationFail(operation: number): void;
  37642. /**
  37643. * Sets the stencil operation to use when depth fails
  37644. * @param operation defines the stencil operation to use when depth fails
  37645. */
  37646. setStencilOperationDepthFail(operation: number): void;
  37647. /**
  37648. * Sets the stencil operation to use when stencil passes
  37649. * @param operation defines the stencil operation to use when stencil passes
  37650. */
  37651. setStencilOperationPass(operation: number): void;
  37652. /**
  37653. * Sets a boolean indicating if the dithering state is enabled or disabled
  37654. * @param value defines the dithering state
  37655. */
  37656. setDitheringState(value: boolean): void;
  37657. /**
  37658. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37659. * @param value defines the rasterizer state
  37660. */
  37661. setRasterizerState(value: boolean): void;
  37662. /**
  37663. * Gets the current depth function
  37664. * @returns a number defining the depth function
  37665. */
  37666. getDepthFunction(): Nullable<number>;
  37667. /**
  37668. * Sets the current depth function
  37669. * @param depthFunc defines the function to use
  37670. */
  37671. setDepthFunction(depthFunc: number): void;
  37672. /**
  37673. * Sets the current depth function to GREATER
  37674. */
  37675. setDepthFunctionToGreater(): void;
  37676. /**
  37677. * Sets the current depth function to GEQUAL
  37678. */
  37679. setDepthFunctionToGreaterOrEqual(): void;
  37680. /**
  37681. * Sets the current depth function to LESS
  37682. */
  37683. setDepthFunctionToLess(): void;
  37684. /**
  37685. * Sets the current depth function to LEQUAL
  37686. */
  37687. setDepthFunctionToLessOrEqual(): void;
  37688. private _cachedStencilBuffer;
  37689. private _cachedStencilFunction;
  37690. private _cachedStencilMask;
  37691. private _cachedStencilOperationPass;
  37692. private _cachedStencilOperationFail;
  37693. private _cachedStencilOperationDepthFail;
  37694. private _cachedStencilReference;
  37695. /**
  37696. * Caches the the state of the stencil buffer
  37697. */
  37698. cacheStencilState(): void;
  37699. /**
  37700. * Restores the state of the stencil buffer
  37701. */
  37702. restoreStencilState(): void;
  37703. /**
  37704. * Directly set the WebGL Viewport
  37705. * @param x defines the x coordinate of the viewport (in screen space)
  37706. * @param y defines the y coordinate of the viewport (in screen space)
  37707. * @param width defines the width of the viewport (in screen space)
  37708. * @param height defines the height of the viewport (in screen space)
  37709. * @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
  37710. */
  37711. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37712. /**
  37713. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37714. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37715. * @param y defines the y-coordinate of the corner of the clear rectangle
  37716. * @param width defines the width of the clear rectangle
  37717. * @param height defines the height of the clear rectangle
  37718. * @param clearColor defines the clear color
  37719. */
  37720. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37721. /**
  37722. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37723. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37724. * @param y defines the y-coordinate of the corner of the clear rectangle
  37725. * @param width defines the width of the clear rectangle
  37726. * @param height defines the height of the clear rectangle
  37727. */
  37728. enableScissor(x: number, y: number, width: number, height: number): void;
  37729. /**
  37730. * Disable previously set scissor test rectangle
  37731. */
  37732. disableScissor(): void;
  37733. protected _reportDrawCall(): void;
  37734. /**
  37735. * Initializes a webVR display and starts listening to display change events
  37736. * The onVRDisplayChangedObservable will be notified upon these changes
  37737. * @returns The onVRDisplayChangedObservable
  37738. */
  37739. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37740. /** @hidden */
  37741. _prepareVRComponent(): void;
  37742. /** @hidden */
  37743. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37744. /** @hidden */
  37745. _submitVRFrame(): void;
  37746. /**
  37747. * Call this function to leave webVR mode
  37748. * Will do nothing if webVR is not supported or if there is no webVR device
  37749. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37750. */
  37751. disableVR(): void;
  37752. /**
  37753. * Gets a boolean indicating that the system is in VR mode and is presenting
  37754. * @returns true if VR mode is engaged
  37755. */
  37756. isVRPresenting(): boolean;
  37757. /** @hidden */
  37758. _requestVRFrame(): void;
  37759. /** @hidden */
  37760. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37761. /**
  37762. * Gets the source code of the vertex shader associated with a specific webGL program
  37763. * @param program defines the program to use
  37764. * @returns a string containing the source code of the vertex shader associated with the program
  37765. */
  37766. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37767. /**
  37768. * Gets the source code of the fragment shader associated with a specific webGL program
  37769. * @param program defines the program to use
  37770. * @returns a string containing the source code of the fragment shader associated with the program
  37771. */
  37772. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37773. /**
  37774. * Sets a depth stencil texture from a render target to the according uniform.
  37775. * @param channel The texture channel
  37776. * @param uniform The uniform to set
  37777. * @param texture The render target texture containing the depth stencil texture to apply
  37778. */
  37779. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37780. /**
  37781. * Sets a texture to the webGL context from a postprocess
  37782. * @param channel defines the channel to use
  37783. * @param postProcess defines the source postprocess
  37784. */
  37785. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37786. /**
  37787. * Binds the output of the passed in post process to the texture channel specified
  37788. * @param channel The channel the texture should be bound to
  37789. * @param postProcess The post process which's output should be bound
  37790. */
  37791. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37792. protected _rebuildBuffers(): void;
  37793. /** @hidden */
  37794. _renderFrame(): void;
  37795. _renderLoop(): void;
  37796. /** @hidden */
  37797. _renderViews(): boolean;
  37798. /**
  37799. * Toggle full screen mode
  37800. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37801. */
  37802. switchFullscreen(requestPointerLock: boolean): void;
  37803. /**
  37804. * Enters full screen mode
  37805. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37806. */
  37807. enterFullscreen(requestPointerLock: boolean): void;
  37808. /**
  37809. * Exits full screen mode
  37810. */
  37811. exitFullscreen(): void;
  37812. /**
  37813. * Enters Pointerlock mode
  37814. */
  37815. enterPointerlock(): void;
  37816. /**
  37817. * Exits Pointerlock mode
  37818. */
  37819. exitPointerlock(): void;
  37820. /**
  37821. * Begin a new frame
  37822. */
  37823. beginFrame(): void;
  37824. /**
  37825. * Enf the current frame
  37826. */
  37827. endFrame(): void;
  37828. resize(): void;
  37829. /**
  37830. * Force a specific size of the canvas
  37831. * @param width defines the new canvas' width
  37832. * @param height defines the new canvas' height
  37833. * @returns true if the size was changed
  37834. */
  37835. setSize(width: number, height: number): boolean;
  37836. /**
  37837. * Updates a dynamic vertex buffer.
  37838. * @param vertexBuffer the vertex buffer to update
  37839. * @param data the data used to update the vertex buffer
  37840. * @param byteOffset the byte offset of the data
  37841. * @param byteLength the byte length of the data
  37842. */
  37843. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37844. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37846. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37847. _releaseTexture(texture: InternalTexture): void;
  37848. /**
  37849. * @hidden
  37850. * Rescales a texture
  37851. * @param source input texutre
  37852. * @param destination destination texture
  37853. * @param scene scene to use to render the resize
  37854. * @param internalFormat format to use when resizing
  37855. * @param onComplete callback to be called when resize has completed
  37856. */
  37857. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37858. /**
  37859. * Gets the current framerate
  37860. * @returns a number representing the framerate
  37861. */
  37862. getFps(): number;
  37863. /**
  37864. * Gets the time spent between current and previous frame
  37865. * @returns a number representing the delta time in ms
  37866. */
  37867. getDeltaTime(): number;
  37868. private _measureFps;
  37869. /** @hidden */
  37870. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37871. /**
  37872. * Update a dynamic index buffer
  37873. * @param indexBuffer defines the target index buffer
  37874. * @param indices defines the data to update
  37875. * @param offset defines the offset in the target index buffer where update should start
  37876. */
  37877. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37878. /**
  37879. * Updates the sample count of a render target texture
  37880. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37881. * @param texture defines the texture to update
  37882. * @param samples defines the sample count to set
  37883. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37884. */
  37885. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37886. /**
  37887. * Updates a depth texture Comparison Mode and Function.
  37888. * If the comparison Function is equal to 0, the mode will be set to none.
  37889. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37890. * @param texture The texture to set the comparison function for
  37891. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37892. */
  37893. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37894. /**
  37895. * Creates a webGL buffer to use with instanciation
  37896. * @param capacity defines the size of the buffer
  37897. * @returns the webGL buffer
  37898. */
  37899. createInstancesBuffer(capacity: number): DataBuffer;
  37900. /**
  37901. * Delete a webGL buffer used with instanciation
  37902. * @param buffer defines the webGL buffer to delete
  37903. */
  37904. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37905. private _clientWaitAsync;
  37906. /** @hidden */
  37907. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37908. dispose(): void;
  37909. private _disableTouchAction;
  37910. /**
  37911. * Display the loading screen
  37912. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37913. */
  37914. displayLoadingUI(): void;
  37915. /**
  37916. * Hide the loading screen
  37917. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37918. */
  37919. hideLoadingUI(): void;
  37920. /**
  37921. * Gets the current loading screen object
  37922. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37923. */
  37924. get loadingScreen(): ILoadingScreen;
  37925. /**
  37926. * Sets the current loading screen object
  37927. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37928. */
  37929. set loadingScreen(loadingScreen: ILoadingScreen);
  37930. /**
  37931. * Sets the current loading screen text
  37932. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37933. */
  37934. set loadingUIText(text: string);
  37935. /**
  37936. * Sets the current loading screen background color
  37937. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37938. */
  37939. set loadingUIBackgroundColor(color: string);
  37940. /** Pointerlock and fullscreen */
  37941. /**
  37942. * Ask the browser to promote the current element to pointerlock mode
  37943. * @param element defines the DOM element to promote
  37944. */
  37945. static _RequestPointerlock(element: HTMLElement): void;
  37946. /**
  37947. * Asks the browser to exit pointerlock mode
  37948. */
  37949. static _ExitPointerlock(): void;
  37950. /**
  37951. * Ask the browser to promote the current element to fullscreen rendering mode
  37952. * @param element defines the DOM element to promote
  37953. */
  37954. static _RequestFullscreen(element: HTMLElement): void;
  37955. /**
  37956. * Asks the browser to exit fullscreen mode
  37957. */
  37958. static _ExitFullscreen(): void;
  37959. }
  37960. }
  37961. declare module BABYLON {
  37962. /**
  37963. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37964. * during the life time of the application.
  37965. */
  37966. export class EngineStore {
  37967. /** Gets the list of created engines */
  37968. static Instances: Engine[];
  37969. /** @hidden */
  37970. static _LastCreatedScene: Nullable<Scene>;
  37971. /**
  37972. * Gets the latest created engine
  37973. */
  37974. static get LastCreatedEngine(): Nullable<Engine>;
  37975. /**
  37976. * Gets the latest created scene
  37977. */
  37978. static get LastCreatedScene(): Nullable<Scene>;
  37979. /**
  37980. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37981. * @ignorenaming
  37982. */
  37983. static UseFallbackTexture: boolean;
  37984. /**
  37985. * Texture content used if a texture cannot loaded
  37986. * @ignorenaming
  37987. */
  37988. static FallbackTexture: string;
  37989. }
  37990. }
  37991. declare module BABYLON {
  37992. /**
  37993. * Helper class that provides a small promise polyfill
  37994. */
  37995. export class PromisePolyfill {
  37996. /**
  37997. * Static function used to check if the polyfill is required
  37998. * If this is the case then the function will inject the polyfill to window.Promise
  37999. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38000. */
  38001. static Apply(force?: boolean): void;
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. /**
  38006. * Interface for screenshot methods with describe argument called `size` as object with options
  38007. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38008. */
  38009. export interface IScreenshotSize {
  38010. /**
  38011. * number in pixels for canvas height
  38012. */
  38013. height?: number;
  38014. /**
  38015. * multiplier allowing render at a higher or lower resolution
  38016. * If value is defined then height and width will be ignored and taken from camera
  38017. */
  38018. precision?: number;
  38019. /**
  38020. * number in pixels for canvas width
  38021. */
  38022. width?: number;
  38023. }
  38024. }
  38025. declare module BABYLON {
  38026. interface IColor4Like {
  38027. r: float;
  38028. g: float;
  38029. b: float;
  38030. a: float;
  38031. }
  38032. /**
  38033. * Class containing a set of static utilities functions
  38034. */
  38035. export class Tools {
  38036. /**
  38037. * Gets or sets the base URL to use to load assets
  38038. */
  38039. static get BaseUrl(): string;
  38040. static set BaseUrl(value: string);
  38041. /**
  38042. * Enable/Disable Custom HTTP Request Headers globally.
  38043. * default = false
  38044. * @see CustomRequestHeaders
  38045. */
  38046. static UseCustomRequestHeaders: boolean;
  38047. /**
  38048. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38049. * i.e. when loading files, where the server/service expects an Authorization header
  38050. */
  38051. static CustomRequestHeaders: {
  38052. [key: string]: string;
  38053. };
  38054. /**
  38055. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38056. */
  38057. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38058. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38059. /**
  38060. * Default behaviour for cors in the application.
  38061. * It can be a string if the expected behavior is identical in the entire app.
  38062. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38063. */
  38064. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38065. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38066. /**
  38067. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38068. * @ignorenaming
  38069. */
  38070. static get UseFallbackTexture(): boolean;
  38071. static set UseFallbackTexture(value: boolean);
  38072. /**
  38073. * Use this object to register external classes like custom textures or material
  38074. * to allow the laoders to instantiate them
  38075. */
  38076. static get RegisteredExternalClasses(): {
  38077. [key: string]: Object;
  38078. };
  38079. static set RegisteredExternalClasses(classes: {
  38080. [key: string]: Object;
  38081. });
  38082. /**
  38083. * Texture content used if a texture cannot loaded
  38084. * @ignorenaming
  38085. */
  38086. static get fallbackTexture(): string;
  38087. static set fallbackTexture(value: string);
  38088. /**
  38089. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38090. * @param u defines the coordinate on X axis
  38091. * @param v defines the coordinate on Y axis
  38092. * @param width defines the width of the source data
  38093. * @param height defines the height of the source data
  38094. * @param pixels defines the source byte array
  38095. * @param color defines the output color
  38096. */
  38097. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38098. /**
  38099. * Interpolates between a and b via alpha
  38100. * @param a The lower value (returned when alpha = 0)
  38101. * @param b The upper value (returned when alpha = 1)
  38102. * @param alpha The interpolation-factor
  38103. * @return The mixed value
  38104. */
  38105. static Mix(a: number, b: number, alpha: number): number;
  38106. /**
  38107. * Tries to instantiate a new object from a given class name
  38108. * @param className defines the class name to instantiate
  38109. * @returns the new object or null if the system was not able to do the instantiation
  38110. */
  38111. static Instantiate(className: string): any;
  38112. /**
  38113. * Provides a slice function that will work even on IE
  38114. * @param data defines the array to slice
  38115. * @param start defines the start of the data (optional)
  38116. * @param end defines the end of the data (optional)
  38117. * @returns the new sliced array
  38118. */
  38119. static Slice<T>(data: T, start?: number, end?: number): T;
  38120. /**
  38121. * Polyfill for setImmediate
  38122. * @param action defines the action to execute after the current execution block
  38123. */
  38124. static SetImmediate(action: () => void): void;
  38125. /**
  38126. * Function indicating if a number is an exponent of 2
  38127. * @param value defines the value to test
  38128. * @returns true if the value is an exponent of 2
  38129. */
  38130. static IsExponentOfTwo(value: number): boolean;
  38131. private static _tmpFloatArray;
  38132. /**
  38133. * Returns the nearest 32-bit single precision float representation of a Number
  38134. * @param value A Number. If the parameter is of a different type, it will get converted
  38135. * to a number or to NaN if it cannot be converted
  38136. * @returns number
  38137. */
  38138. static FloatRound(value: number): number;
  38139. /**
  38140. * Extracts the filename from a path
  38141. * @param path defines the path to use
  38142. * @returns the filename
  38143. */
  38144. static GetFilename(path: string): string;
  38145. /**
  38146. * Extracts the "folder" part of a path (everything before the filename).
  38147. * @param uri The URI to extract the info from
  38148. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38149. * @returns The "folder" part of the path
  38150. */
  38151. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38152. /**
  38153. * Extracts text content from a DOM element hierarchy
  38154. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38155. */
  38156. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38157. /**
  38158. * Convert an angle in radians to degrees
  38159. * @param angle defines the angle to convert
  38160. * @returns the angle in degrees
  38161. */
  38162. static ToDegrees(angle: number): number;
  38163. /**
  38164. * Convert an angle in degrees to radians
  38165. * @param angle defines the angle to convert
  38166. * @returns the angle in radians
  38167. */
  38168. static ToRadians(angle: number): number;
  38169. /**
  38170. * Returns an array if obj is not an array
  38171. * @param obj defines the object to evaluate as an array
  38172. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38173. * @returns either obj directly if obj is an array or a new array containing obj
  38174. */
  38175. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38176. /**
  38177. * Gets the pointer prefix to use
  38178. * @param engine defines the engine we are finding the prefix for
  38179. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38180. */
  38181. static GetPointerPrefix(engine: Engine): string;
  38182. /**
  38183. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38184. * @param url define the url we are trying
  38185. * @param element define the dom element where to configure the cors policy
  38186. */
  38187. static SetCorsBehavior(url: string | string[], element: {
  38188. crossOrigin: string | null;
  38189. }): void;
  38190. /**
  38191. * Removes unwanted characters from an url
  38192. * @param url defines the url to clean
  38193. * @returns the cleaned url
  38194. */
  38195. static CleanUrl(url: string): string;
  38196. /**
  38197. * Gets or sets a function used to pre-process url before using them to load assets
  38198. */
  38199. static get PreprocessUrl(): (url: string) => string;
  38200. static set PreprocessUrl(processor: (url: string) => string);
  38201. /**
  38202. * Loads an image as an HTMLImageElement.
  38203. * @param input url string, ArrayBuffer, or Blob to load
  38204. * @param onLoad callback called when the image successfully loads
  38205. * @param onError callback called when the image fails to load
  38206. * @param offlineProvider offline provider for caching
  38207. * @param mimeType optional mime type
  38208. * @returns the HTMLImageElement of the loaded image
  38209. */
  38210. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38211. /**
  38212. * Loads a file from a url
  38213. * @param url url string, ArrayBuffer, or Blob to load
  38214. * @param onSuccess callback called when the file successfully loads
  38215. * @param onProgress callback called while file is loading (if the server supports this mode)
  38216. * @param offlineProvider defines the offline provider for caching
  38217. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38218. * @param onError callback called when the file fails to load
  38219. * @returns a file request object
  38220. */
  38221. 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;
  38222. /**
  38223. * Loads a file from a url
  38224. * @param url the file url to load
  38225. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38226. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38227. */
  38228. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38229. /**
  38230. * Load a script (identified by an url). When the url returns, the
  38231. * content of this file is added into a new script element, attached to the DOM (body element)
  38232. * @param scriptUrl defines the url of the script to laod
  38233. * @param onSuccess defines the callback called when the script is loaded
  38234. * @param onError defines the callback to call if an error occurs
  38235. * @param scriptId defines the id of the script element
  38236. */
  38237. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38238. /**
  38239. * Load an asynchronous script (identified by an url). When the url returns, the
  38240. * content of this file is added into a new script element, attached to the DOM (body element)
  38241. * @param scriptUrl defines the url of the script to laod
  38242. * @param scriptId defines the id of the script element
  38243. * @returns a promise request object
  38244. */
  38245. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38246. /**
  38247. * Loads a file from a blob
  38248. * @param fileToLoad defines the blob to use
  38249. * @param callback defines the callback to call when data is loaded
  38250. * @param progressCallback defines the callback to call during loading process
  38251. * @returns a file request object
  38252. */
  38253. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38254. /**
  38255. * Reads a file from a File object
  38256. * @param file defines the file to load
  38257. * @param onSuccess defines the callback to call when data is loaded
  38258. * @param onProgress defines the callback to call during loading process
  38259. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38260. * @param onError defines the callback to call when an error occurs
  38261. * @returns a file request object
  38262. */
  38263. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38264. /**
  38265. * Creates a data url from a given string content
  38266. * @param content defines the content to convert
  38267. * @returns the new data url link
  38268. */
  38269. static FileAsURL(content: string): string;
  38270. /**
  38271. * Format the given number to a specific decimal format
  38272. * @param value defines the number to format
  38273. * @param decimals defines the number of decimals to use
  38274. * @returns the formatted string
  38275. */
  38276. static Format(value: number, decimals?: number): string;
  38277. /**
  38278. * Tries to copy an object by duplicating every property
  38279. * @param source defines the source object
  38280. * @param destination defines the target object
  38281. * @param doNotCopyList defines a list of properties to avoid
  38282. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38283. */
  38284. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38285. /**
  38286. * Gets a boolean indicating if the given object has no own property
  38287. * @param obj defines the object to test
  38288. * @returns true if object has no own property
  38289. */
  38290. static IsEmpty(obj: any): boolean;
  38291. /**
  38292. * Function used to register events at window level
  38293. * @param windowElement defines the Window object to use
  38294. * @param events defines the events to register
  38295. */
  38296. static RegisterTopRootEvents(windowElement: Window, events: {
  38297. name: string;
  38298. handler: Nullable<(e: FocusEvent) => any>;
  38299. }[]): void;
  38300. /**
  38301. * Function used to unregister events from window level
  38302. * @param windowElement defines the Window object to use
  38303. * @param events defines the events to unregister
  38304. */
  38305. static UnregisterTopRootEvents(windowElement: Window, events: {
  38306. name: string;
  38307. handler: Nullable<(e: FocusEvent) => any>;
  38308. }[]): void;
  38309. /**
  38310. * @ignore
  38311. */
  38312. static _ScreenshotCanvas: HTMLCanvasElement;
  38313. /**
  38314. * Dumps the current bound framebuffer
  38315. * @param width defines the rendering width
  38316. * @param height defines the rendering height
  38317. * @param engine defines the hosting engine
  38318. * @param successCallback defines the callback triggered once the data are available
  38319. * @param mimeType defines the mime type of the result
  38320. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38321. */
  38322. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38323. /**
  38324. * Converts the canvas data to blob.
  38325. * This acts as a polyfill for browsers not supporting the to blob function.
  38326. * @param canvas Defines the canvas to extract the data from
  38327. * @param successCallback Defines the callback triggered once the data are available
  38328. * @param mimeType Defines the mime type of the result
  38329. */
  38330. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38331. /**
  38332. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38333. * @param successCallback defines the callback triggered once the data are available
  38334. * @param mimeType defines the mime type of the result
  38335. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38336. */
  38337. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38338. /**
  38339. * Downloads a blob in the browser
  38340. * @param blob defines the blob to download
  38341. * @param fileName defines the name of the downloaded file
  38342. */
  38343. static Download(blob: Blob, fileName: string): void;
  38344. /**
  38345. * Captures a screenshot of the current rendering
  38346. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38347. * @param engine defines the rendering engine
  38348. * @param camera defines the source camera
  38349. * @param size This parameter can be set to a single number or to an object with the
  38350. * following (optional) properties: precision, width, height. If a single number is passed,
  38351. * it will be used for both width and height. If an object is passed, the screenshot size
  38352. * will be derived from the parameters. The precision property is a multiplier allowing
  38353. * rendering at a higher or lower resolution
  38354. * @param successCallback defines the callback receives a single parameter which contains the
  38355. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38356. * src parameter of an <img> to display it
  38357. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38358. * Check your browser for supported MIME types
  38359. */
  38360. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38361. /**
  38362. * Captures a screenshot of the current rendering
  38363. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38364. * @param engine defines the rendering engine
  38365. * @param camera defines the source camera
  38366. * @param size This parameter can be set to a single number or to an object with the
  38367. * following (optional) properties: precision, width, height. If a single number is passed,
  38368. * it will be used for both width and height. If an object is passed, the screenshot size
  38369. * will be derived from the parameters. The precision property is a multiplier allowing
  38370. * rendering at a higher or lower resolution
  38371. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38372. * Check your browser for supported MIME types
  38373. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38374. * to the src parameter of an <img> to display it
  38375. */
  38376. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38377. /**
  38378. * Generates an image screenshot from the specified camera.
  38379. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38380. * @param engine The engine to use for rendering
  38381. * @param camera The camera to use for rendering
  38382. * @param size This parameter can be set to a single number or to an object with the
  38383. * following (optional) properties: precision, width, height. If a single number is passed,
  38384. * it will be used for both width and height. If an object is passed, the screenshot size
  38385. * will be derived from the parameters. The precision property is a multiplier allowing
  38386. * rendering at a higher or lower resolution
  38387. * @param successCallback The callback receives a single parameter which contains the
  38388. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38389. * src parameter of an <img> to display it
  38390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38391. * Check your browser for supported MIME types
  38392. * @param samples Texture samples (default: 1)
  38393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38394. * @param fileName A name for for the downloaded file.
  38395. */
  38396. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38397. /**
  38398. * Generates an image screenshot from the specified camera.
  38399. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38400. * @param engine The engine to use for rendering
  38401. * @param camera The camera to use for rendering
  38402. * @param size This parameter can be set to a single number or to an object with the
  38403. * following (optional) properties: precision, width, height. If a single number is passed,
  38404. * it will be used for both width and height. If an object is passed, the screenshot size
  38405. * will be derived from the parameters. The precision property is a multiplier allowing
  38406. * rendering at a higher or lower resolution
  38407. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38408. * Check your browser for supported MIME types
  38409. * @param samples Texture samples (default: 1)
  38410. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38411. * @param fileName A name for for the downloaded file.
  38412. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38413. * to the src parameter of an <img> to display it
  38414. */
  38415. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38416. /**
  38417. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38418. * Be aware Math.random() could cause collisions, but:
  38419. * "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"
  38420. * @returns a pseudo random id
  38421. */
  38422. static RandomId(): string;
  38423. /**
  38424. * Test if the given uri is a base64 string
  38425. * @param uri The uri to test
  38426. * @return True if the uri is a base64 string or false otherwise
  38427. */
  38428. static IsBase64(uri: string): boolean;
  38429. /**
  38430. * Decode the given base64 uri.
  38431. * @param uri The uri to decode
  38432. * @return The decoded base64 data.
  38433. */
  38434. static DecodeBase64(uri: string): ArrayBuffer;
  38435. /**
  38436. * Gets the absolute url.
  38437. * @param url the input url
  38438. * @return the absolute url
  38439. */
  38440. static GetAbsoluteUrl(url: string): string;
  38441. /**
  38442. * No log
  38443. */
  38444. static readonly NoneLogLevel: number;
  38445. /**
  38446. * Only message logs
  38447. */
  38448. static readonly MessageLogLevel: number;
  38449. /**
  38450. * Only warning logs
  38451. */
  38452. static readonly WarningLogLevel: number;
  38453. /**
  38454. * Only error logs
  38455. */
  38456. static readonly ErrorLogLevel: number;
  38457. /**
  38458. * All logs
  38459. */
  38460. static readonly AllLogLevel: number;
  38461. /**
  38462. * Gets a value indicating the number of loading errors
  38463. * @ignorenaming
  38464. */
  38465. static get errorsCount(): number;
  38466. /**
  38467. * Callback called when a new log is added
  38468. */
  38469. static OnNewCacheEntry: (entry: string) => void;
  38470. /**
  38471. * Log a message to the console
  38472. * @param message defines the message to log
  38473. */
  38474. static Log(message: string): void;
  38475. /**
  38476. * Write a warning message to the console
  38477. * @param message defines the message to log
  38478. */
  38479. static Warn(message: string): void;
  38480. /**
  38481. * Write an error message to the console
  38482. * @param message defines the message to log
  38483. */
  38484. static Error(message: string): void;
  38485. /**
  38486. * Gets current log cache (list of logs)
  38487. */
  38488. static get LogCache(): string;
  38489. /**
  38490. * Clears the log cache
  38491. */
  38492. static ClearLogCache(): void;
  38493. /**
  38494. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38495. */
  38496. static set LogLevels(level: number);
  38497. /**
  38498. * Checks if the window object exists
  38499. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38500. */
  38501. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38502. /**
  38503. * No performance log
  38504. */
  38505. static readonly PerformanceNoneLogLevel: number;
  38506. /**
  38507. * Use user marks to log performance
  38508. */
  38509. static readonly PerformanceUserMarkLogLevel: number;
  38510. /**
  38511. * Log performance to the console
  38512. */
  38513. static readonly PerformanceConsoleLogLevel: number;
  38514. private static _performance;
  38515. /**
  38516. * Sets the current performance log level
  38517. */
  38518. static set PerformanceLogLevel(level: number);
  38519. private static _StartPerformanceCounterDisabled;
  38520. private static _EndPerformanceCounterDisabled;
  38521. private static _StartUserMark;
  38522. private static _EndUserMark;
  38523. private static _StartPerformanceConsole;
  38524. private static _EndPerformanceConsole;
  38525. /**
  38526. * Starts a performance counter
  38527. */
  38528. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38529. /**
  38530. * Ends a specific performance coutner
  38531. */
  38532. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38533. /**
  38534. * Gets either window.performance.now() if supported or Date.now() else
  38535. */
  38536. static get Now(): number;
  38537. /**
  38538. * This method will return the name of the class used to create the instance of the given object.
  38539. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38540. * @param object the object to get the class name from
  38541. * @param isType defines if the object is actually a type
  38542. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38543. */
  38544. static GetClassName(object: any, isType?: boolean): string;
  38545. /**
  38546. * Gets the first element of an array satisfying a given predicate
  38547. * @param array defines the array to browse
  38548. * @param predicate defines the predicate to use
  38549. * @returns null if not found or the element
  38550. */
  38551. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38552. /**
  38553. * This method will return the name of the full name of the class, including its owning module (if any).
  38554. * 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).
  38555. * @param object the object to get the class name from
  38556. * @param isType defines if the object is actually a type
  38557. * @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.
  38558. * @ignorenaming
  38559. */
  38560. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38561. /**
  38562. * Returns a promise that resolves after the given amount of time.
  38563. * @param delay Number of milliseconds to delay
  38564. * @returns Promise that resolves after the given amount of time
  38565. */
  38566. static DelayAsync(delay: number): Promise<void>;
  38567. /**
  38568. * Utility function to detect if the current user agent is Safari
  38569. * @returns whether or not the current user agent is safari
  38570. */
  38571. static IsSafari(): boolean;
  38572. }
  38573. /**
  38574. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38575. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38576. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38577. * @param name The name of the class, case should be preserved
  38578. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38579. */
  38580. export function className(name: string, module?: string): (target: Object) => void;
  38581. /**
  38582. * An implementation of a loop for asynchronous functions.
  38583. */
  38584. export class AsyncLoop {
  38585. /**
  38586. * Defines the number of iterations for the loop
  38587. */
  38588. iterations: number;
  38589. /**
  38590. * Defines the current index of the loop.
  38591. */
  38592. index: number;
  38593. private _done;
  38594. private _fn;
  38595. private _successCallback;
  38596. /**
  38597. * Constructor.
  38598. * @param iterations the number of iterations.
  38599. * @param func the function to run each iteration
  38600. * @param successCallback the callback that will be called upon succesful execution
  38601. * @param offset starting offset.
  38602. */
  38603. constructor(
  38604. /**
  38605. * Defines the number of iterations for the loop
  38606. */
  38607. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38608. /**
  38609. * Execute the next iteration. Must be called after the last iteration was finished.
  38610. */
  38611. executeNext(): void;
  38612. /**
  38613. * Break the loop and run the success callback.
  38614. */
  38615. breakLoop(): void;
  38616. /**
  38617. * Create and run an async loop.
  38618. * @param iterations the number of iterations.
  38619. * @param fn the function to run each iteration
  38620. * @param successCallback the callback that will be called upon succesful execution
  38621. * @param offset starting offset.
  38622. * @returns the created async loop object
  38623. */
  38624. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38625. /**
  38626. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38627. * @param iterations total number of iterations
  38628. * @param syncedIterations number of synchronous iterations in each async iteration.
  38629. * @param fn the function to call each iteration.
  38630. * @param callback a success call back that will be called when iterating stops.
  38631. * @param breakFunction a break condition (optional)
  38632. * @param timeout timeout settings for the setTimeout function. default - 0.
  38633. * @returns the created async loop object
  38634. */
  38635. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38636. }
  38637. }
  38638. declare module BABYLON {
  38639. /**
  38640. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38641. * The underlying implementation relies on an associative array to ensure the best performances.
  38642. * The value can be anything including 'null' but except 'undefined'
  38643. */
  38644. export class StringDictionary<T> {
  38645. /**
  38646. * This will clear this dictionary and copy the content from the 'source' one.
  38647. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38648. * @param source the dictionary to take the content from and copy to this dictionary
  38649. */
  38650. copyFrom(source: StringDictionary<T>): void;
  38651. /**
  38652. * Get a value based from its key
  38653. * @param key the given key to get the matching value from
  38654. * @return the value if found, otherwise undefined is returned
  38655. */
  38656. get(key: string): T | undefined;
  38657. /**
  38658. * Get a value from its key or add it if it doesn't exist.
  38659. * This method will ensure you that a given key/data will be present in the dictionary.
  38660. * @param key the given key to get the matching value from
  38661. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38662. * The factory will only be invoked if there's no data for the given key.
  38663. * @return the value corresponding to the key.
  38664. */
  38665. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38666. /**
  38667. * Get a value from its key if present in the dictionary otherwise add it
  38668. * @param key the key to get the value from
  38669. * @param val if there's no such key/value pair in the dictionary add it with this value
  38670. * @return the value corresponding to the key
  38671. */
  38672. getOrAdd(key: string, val: T): T;
  38673. /**
  38674. * Check if there's a given key in the dictionary
  38675. * @param key the key to check for
  38676. * @return true if the key is present, false otherwise
  38677. */
  38678. contains(key: string): boolean;
  38679. /**
  38680. * Add a new key and its corresponding value
  38681. * @param key the key to add
  38682. * @param value the value corresponding to the key
  38683. * @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
  38684. */
  38685. add(key: string, value: T): boolean;
  38686. /**
  38687. * Update a specific value associated to a key
  38688. * @param key defines the key to use
  38689. * @param value defines the value to store
  38690. * @returns true if the value was updated (or false if the key was not found)
  38691. */
  38692. set(key: string, value: T): boolean;
  38693. /**
  38694. * Get the element of the given key and remove it from the dictionary
  38695. * @param key defines the key to search
  38696. * @returns the value associated with the key or null if not found
  38697. */
  38698. getAndRemove(key: string): Nullable<T>;
  38699. /**
  38700. * Remove a key/value from the dictionary.
  38701. * @param key the key to remove
  38702. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38703. */
  38704. remove(key: string): boolean;
  38705. /**
  38706. * Clear the whole content of the dictionary
  38707. */
  38708. clear(): void;
  38709. /**
  38710. * Gets the current count
  38711. */
  38712. get count(): number;
  38713. /**
  38714. * Execute a callback on each key/val of the dictionary.
  38715. * Note that you can remove any element in this dictionary in the callback implementation
  38716. * @param callback the callback to execute on a given key/value pair
  38717. */
  38718. forEach(callback: (key: string, val: T) => void): void;
  38719. /**
  38720. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38721. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38722. * Note that you can remove any element in this dictionary in the callback implementation
  38723. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38724. * @returns the first item
  38725. */
  38726. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38727. private _count;
  38728. private _data;
  38729. }
  38730. }
  38731. declare module BABYLON {
  38732. /** @hidden */
  38733. export interface ICollisionCoordinator {
  38734. createCollider(): Collider;
  38735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38736. init(scene: Scene): void;
  38737. }
  38738. /** @hidden */
  38739. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38740. private _scene;
  38741. private _scaledPosition;
  38742. private _scaledVelocity;
  38743. private _finalPosition;
  38744. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38745. createCollider(): Collider;
  38746. init(scene: Scene): void;
  38747. private _collideWithWorld;
  38748. }
  38749. }
  38750. declare module BABYLON {
  38751. /**
  38752. * Class used to manage all inputs for the scene.
  38753. */
  38754. export class InputManager {
  38755. /** The distance in pixel that you have to move to prevent some events */
  38756. static DragMovementThreshold: number;
  38757. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38758. static LongPressDelay: number;
  38759. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38760. static DoubleClickDelay: number;
  38761. /** If you need to check double click without raising a single click at first click, enable this flag */
  38762. static ExclusiveDoubleClickMode: boolean;
  38763. /** 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. */
  38764. private _alreadyAttached;
  38765. private _wheelEventName;
  38766. private _onPointerMove;
  38767. private _onPointerDown;
  38768. private _onPointerUp;
  38769. private _initClickEvent;
  38770. private _initActionManager;
  38771. private _delayedSimpleClick;
  38772. private _delayedSimpleClickTimeout;
  38773. private _previousDelayedSimpleClickTimeout;
  38774. private _meshPickProceed;
  38775. private _previousButtonPressed;
  38776. private _currentPickResult;
  38777. private _previousPickResult;
  38778. private _totalPointersPressed;
  38779. private _doubleClickOccured;
  38780. private _pointerOverMesh;
  38781. private _pickedDownMesh;
  38782. private _pickedUpMesh;
  38783. private _pointerX;
  38784. private _pointerY;
  38785. private _unTranslatedPointerX;
  38786. private _unTranslatedPointerY;
  38787. private _startingPointerPosition;
  38788. private _previousStartingPointerPosition;
  38789. private _startingPointerTime;
  38790. private _previousStartingPointerTime;
  38791. private _pointerCaptures;
  38792. private _onKeyDown;
  38793. private _onKeyUp;
  38794. private _onCanvasFocusObserver;
  38795. private _onCanvasBlurObserver;
  38796. private _scene;
  38797. /**
  38798. * Creates a new InputManager
  38799. * @param scene defines the hosting scene
  38800. */
  38801. constructor(scene: Scene);
  38802. /**
  38803. * Gets the mesh that is currently under the pointer
  38804. */
  38805. get meshUnderPointer(): Nullable<AbstractMesh>;
  38806. /**
  38807. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38808. */
  38809. get unTranslatedPointer(): Vector2;
  38810. /**
  38811. * Gets or sets the current on-screen X position of the pointer
  38812. */
  38813. get pointerX(): number;
  38814. set pointerX(value: number);
  38815. /**
  38816. * Gets or sets the current on-screen Y position of the pointer
  38817. */
  38818. get pointerY(): number;
  38819. set pointerY(value: number);
  38820. private _updatePointerPosition;
  38821. private _processPointerMove;
  38822. private _setRayOnPointerInfo;
  38823. private _checkPrePointerObservable;
  38824. /**
  38825. * Use this method to simulate a pointer move on a mesh
  38826. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38827. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38828. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38829. */
  38830. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38831. /**
  38832. * Use this method to simulate a pointer down on a mesh
  38833. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38834. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38835. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38836. */
  38837. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38838. private _processPointerDown;
  38839. /** @hidden */
  38840. _isPointerSwiping(): boolean;
  38841. /**
  38842. * Use this method to simulate a pointer up on a mesh
  38843. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38844. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38845. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38846. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38847. */
  38848. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38849. private _processPointerUp;
  38850. /**
  38851. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38852. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38853. * @returns true if the pointer was captured
  38854. */
  38855. isPointerCaptured(pointerId?: number): boolean;
  38856. /**
  38857. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38858. * @param attachUp defines if you want to attach events to pointerup
  38859. * @param attachDown defines if you want to attach events to pointerdown
  38860. * @param attachMove defines if you want to attach events to pointermove
  38861. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38862. */
  38863. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38864. /**
  38865. * Detaches all event handlers
  38866. */
  38867. detachControl(): void;
  38868. /**
  38869. * Force the value of meshUnderPointer
  38870. * @param mesh defines the mesh to use
  38871. */
  38872. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38873. /**
  38874. * Gets the mesh under the pointer
  38875. * @returns a Mesh or null if no mesh is under the pointer
  38876. */
  38877. getPointerOverMesh(): Nullable<AbstractMesh>;
  38878. }
  38879. }
  38880. declare module BABYLON {
  38881. /**
  38882. * This class defines the direct association between an animation and a target
  38883. */
  38884. export class TargetedAnimation {
  38885. /**
  38886. * Animation to perform
  38887. */
  38888. animation: Animation;
  38889. /**
  38890. * Target to animate
  38891. */
  38892. target: any;
  38893. /**
  38894. * Returns the string "TargetedAnimation"
  38895. * @returns "TargetedAnimation"
  38896. */
  38897. getClassName(): string;
  38898. /**
  38899. * Serialize the object
  38900. * @returns the JSON object representing the current entity
  38901. */
  38902. serialize(): any;
  38903. }
  38904. /**
  38905. * Use this class to create coordinated animations on multiple targets
  38906. */
  38907. export class AnimationGroup implements IDisposable {
  38908. /** The name of the animation group */
  38909. name: string;
  38910. private _scene;
  38911. private _targetedAnimations;
  38912. private _animatables;
  38913. private _from;
  38914. private _to;
  38915. private _isStarted;
  38916. private _isPaused;
  38917. private _speedRatio;
  38918. private _loopAnimation;
  38919. private _isAdditive;
  38920. /**
  38921. * Gets or sets the unique id of the node
  38922. */
  38923. uniqueId: number;
  38924. /**
  38925. * This observable will notify when one animation have ended
  38926. */
  38927. onAnimationEndObservable: Observable<TargetedAnimation>;
  38928. /**
  38929. * Observer raised when one animation loops
  38930. */
  38931. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38932. /**
  38933. * Observer raised when all animations have looped
  38934. */
  38935. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38936. /**
  38937. * This observable will notify when all animations have ended.
  38938. */
  38939. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38940. /**
  38941. * This observable will notify when all animations have paused.
  38942. */
  38943. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38944. /**
  38945. * This observable will notify when all animations are playing.
  38946. */
  38947. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38948. /**
  38949. * Gets the first frame
  38950. */
  38951. get from(): number;
  38952. /**
  38953. * Gets the last frame
  38954. */
  38955. get to(): number;
  38956. /**
  38957. * Define if the animations are started
  38958. */
  38959. get isStarted(): boolean;
  38960. /**
  38961. * Gets a value indicating that the current group is playing
  38962. */
  38963. get isPlaying(): boolean;
  38964. /**
  38965. * Gets or sets the speed ratio to use for all animations
  38966. */
  38967. get speedRatio(): number;
  38968. /**
  38969. * Gets or sets the speed ratio to use for all animations
  38970. */
  38971. set speedRatio(value: number);
  38972. /**
  38973. * Gets or sets if all animations should loop or not
  38974. */
  38975. get loopAnimation(): boolean;
  38976. set loopAnimation(value: boolean);
  38977. /**
  38978. * Gets or sets if all animations should be evaluated additively
  38979. */
  38980. get isAdditive(): boolean;
  38981. set isAdditive(value: boolean);
  38982. /**
  38983. * Gets the targeted animations for this animation group
  38984. */
  38985. get targetedAnimations(): Array<TargetedAnimation>;
  38986. /**
  38987. * returning the list of animatables controlled by this animation group.
  38988. */
  38989. get animatables(): Array<Animatable>;
  38990. /**
  38991. * Gets the list of target animations
  38992. */
  38993. get children(): TargetedAnimation[];
  38994. /**
  38995. * Instantiates a new Animation Group.
  38996. * This helps managing several animations at once.
  38997. * @see https://doc.babylonjs.com/how_to/group
  38998. * @param name Defines the name of the group
  38999. * @param scene Defines the scene the group belongs to
  39000. */
  39001. constructor(
  39002. /** The name of the animation group */
  39003. name: string, scene?: Nullable<Scene>);
  39004. /**
  39005. * Add an animation (with its target) in the group
  39006. * @param animation defines the animation we want to add
  39007. * @param target defines the target of the animation
  39008. * @returns the TargetedAnimation object
  39009. */
  39010. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39011. /**
  39012. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39013. * It can add constant keys at begin or end
  39014. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39015. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39016. * @returns the animation group
  39017. */
  39018. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39019. private _animationLoopCount;
  39020. private _animationLoopFlags;
  39021. private _processLoop;
  39022. /**
  39023. * Start all animations on given targets
  39024. * @param loop defines if animations must loop
  39025. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39026. * @param from defines the from key (optional)
  39027. * @param to defines the to key (optional)
  39028. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39029. * @returns the current animation group
  39030. */
  39031. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39032. /**
  39033. * Pause all animations
  39034. * @returns the animation group
  39035. */
  39036. pause(): AnimationGroup;
  39037. /**
  39038. * Play all animations to initial state
  39039. * This function will start() the animations if they were not started or will restart() them if they were paused
  39040. * @param loop defines if animations must loop
  39041. * @returns the animation group
  39042. */
  39043. play(loop?: boolean): AnimationGroup;
  39044. /**
  39045. * Reset all animations to initial state
  39046. * @returns the animation group
  39047. */
  39048. reset(): AnimationGroup;
  39049. /**
  39050. * Restart animations from key 0
  39051. * @returns the animation group
  39052. */
  39053. restart(): AnimationGroup;
  39054. /**
  39055. * Stop all animations
  39056. * @returns the animation group
  39057. */
  39058. stop(): AnimationGroup;
  39059. /**
  39060. * Set animation weight for all animatables
  39061. * @param weight defines the weight to use
  39062. * @return the animationGroup
  39063. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39064. */
  39065. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39066. /**
  39067. * Synchronize and normalize all animatables with a source animatable
  39068. * @param root defines the root animatable to synchronize with
  39069. * @return the animationGroup
  39070. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39071. */
  39072. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39073. /**
  39074. * Goes to a specific frame in this animation group
  39075. * @param frame the frame number to go to
  39076. * @return the animationGroup
  39077. */
  39078. goToFrame(frame: number): AnimationGroup;
  39079. /**
  39080. * Dispose all associated resources
  39081. */
  39082. dispose(): void;
  39083. private _checkAnimationGroupEnded;
  39084. /**
  39085. * Clone the current animation group and returns a copy
  39086. * @param newName defines the name of the new group
  39087. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39088. * @returns the new aniamtion group
  39089. */
  39090. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39091. /**
  39092. * Serializes the animationGroup to an object
  39093. * @returns Serialized object
  39094. */
  39095. serialize(): any;
  39096. /**
  39097. * Returns a new AnimationGroup object parsed from the source provided.
  39098. * @param parsedAnimationGroup defines the source
  39099. * @param scene defines the scene that will receive the animationGroup
  39100. * @returns a new AnimationGroup
  39101. */
  39102. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39103. /**
  39104. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39105. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39106. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39107. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39108. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39109. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39110. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39111. */
  39112. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39113. /**
  39114. * Returns the string "AnimationGroup"
  39115. * @returns "AnimationGroup"
  39116. */
  39117. getClassName(): string;
  39118. /**
  39119. * Creates a detailled string about the object
  39120. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39121. * @returns a string representing the object
  39122. */
  39123. toString(fullDetails?: boolean): string;
  39124. }
  39125. }
  39126. declare module BABYLON {
  39127. /**
  39128. * Define an interface for all classes that will hold resources
  39129. */
  39130. export interface IDisposable {
  39131. /**
  39132. * Releases all held resources
  39133. */
  39134. dispose(): void;
  39135. }
  39136. /** Interface defining initialization parameters for Scene class */
  39137. export interface SceneOptions {
  39138. /**
  39139. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39140. * It will improve performance when the number of geometries becomes important.
  39141. */
  39142. useGeometryUniqueIdsMap?: boolean;
  39143. /**
  39144. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39145. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39146. */
  39147. useMaterialMeshMap?: boolean;
  39148. /**
  39149. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39150. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39151. */
  39152. useClonedMeshMap?: boolean;
  39153. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39154. virtual?: boolean;
  39155. }
  39156. /**
  39157. * Represents a scene to be rendered by the engine.
  39158. * @see https://doc.babylonjs.com/features/scene
  39159. */
  39160. export class Scene extends AbstractScene implements IAnimatable {
  39161. /** The fog is deactivated */
  39162. static readonly FOGMODE_NONE: number;
  39163. /** The fog density is following an exponential function */
  39164. static readonly FOGMODE_EXP: number;
  39165. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39166. static readonly FOGMODE_EXP2: number;
  39167. /** The fog density is following a linear function. */
  39168. static readonly FOGMODE_LINEAR: number;
  39169. /**
  39170. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39171. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39172. */
  39173. static MinDeltaTime: number;
  39174. /**
  39175. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39176. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39177. */
  39178. static MaxDeltaTime: number;
  39179. /**
  39180. * Factory used to create the default material.
  39181. * @param name The name of the material to create
  39182. * @param scene The scene to create the material for
  39183. * @returns The default material
  39184. */
  39185. static DefaultMaterialFactory(scene: Scene): Material;
  39186. /**
  39187. * Factory used to create the a collision coordinator.
  39188. * @returns The collision coordinator
  39189. */
  39190. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39191. /** @hidden */
  39192. _inputManager: InputManager;
  39193. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39194. cameraToUseForPointers: Nullable<Camera>;
  39195. /** @hidden */
  39196. readonly _isScene: boolean;
  39197. /** @hidden */
  39198. _blockEntityCollection: boolean;
  39199. /**
  39200. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39201. */
  39202. autoClear: boolean;
  39203. /**
  39204. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39205. */
  39206. autoClearDepthAndStencil: boolean;
  39207. /**
  39208. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39209. */
  39210. clearColor: Color4;
  39211. /**
  39212. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39213. */
  39214. ambientColor: Color3;
  39215. /**
  39216. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39217. * It should only be one of the following (if not the default embedded one):
  39218. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39219. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39220. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39221. * The material properties need to be setup according to the type of texture in use.
  39222. */
  39223. environmentBRDFTexture: BaseTexture;
  39224. /** @hidden */
  39225. protected _environmentTexture: Nullable<BaseTexture>;
  39226. /**
  39227. * Texture used in all pbr material as the reflection texture.
  39228. * As in the majority of the scene they are the same (exception for multi room and so on),
  39229. * this is easier to reference from here than from all the materials.
  39230. */
  39231. get environmentTexture(): Nullable<BaseTexture>;
  39232. /**
  39233. * Texture used in all pbr material as the reflection texture.
  39234. * As in the majority of the scene they are the same (exception for multi room and so on),
  39235. * this is easier to set here than in all the materials.
  39236. */
  39237. set environmentTexture(value: Nullable<BaseTexture>);
  39238. /** @hidden */
  39239. protected _environmentIntensity: number;
  39240. /**
  39241. * Intensity of the environment in all pbr material.
  39242. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39243. * As in the majority of the scene they are the same (exception for multi room and so on),
  39244. * this is easier to reference from here than from all the materials.
  39245. */
  39246. get environmentIntensity(): number;
  39247. /**
  39248. * Intensity of the environment in all pbr material.
  39249. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39250. * As in the majority of the scene they are the same (exception for multi room and so on),
  39251. * this is easier to set here than in all the materials.
  39252. */
  39253. set environmentIntensity(value: number);
  39254. /** @hidden */
  39255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39256. /**
  39257. * Default image processing configuration used either in the rendering
  39258. * Forward main pass or through the imageProcessingPostProcess if present.
  39259. * As in the majority of the scene they are the same (exception for multi camera),
  39260. * this is easier to reference from here than from all the materials and post process.
  39261. *
  39262. * No setter as we it is a shared configuration, you can set the values instead.
  39263. */
  39264. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39265. private _forceWireframe;
  39266. /**
  39267. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39268. */
  39269. set forceWireframe(value: boolean);
  39270. get forceWireframe(): boolean;
  39271. private _skipFrustumClipping;
  39272. /**
  39273. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39274. */
  39275. set skipFrustumClipping(value: boolean);
  39276. get skipFrustumClipping(): boolean;
  39277. private _forcePointsCloud;
  39278. /**
  39279. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39280. */
  39281. set forcePointsCloud(value: boolean);
  39282. get forcePointsCloud(): boolean;
  39283. /**
  39284. * Gets or sets the active clipplane 1
  39285. */
  39286. clipPlane: Nullable<Plane>;
  39287. /**
  39288. * Gets or sets the active clipplane 2
  39289. */
  39290. clipPlane2: Nullable<Plane>;
  39291. /**
  39292. * Gets or sets the active clipplane 3
  39293. */
  39294. clipPlane3: Nullable<Plane>;
  39295. /**
  39296. * Gets or sets the active clipplane 4
  39297. */
  39298. clipPlane4: Nullable<Plane>;
  39299. /**
  39300. * Gets or sets the active clipplane 5
  39301. */
  39302. clipPlane5: Nullable<Plane>;
  39303. /**
  39304. * Gets or sets the active clipplane 6
  39305. */
  39306. clipPlane6: Nullable<Plane>;
  39307. /**
  39308. * Gets or sets a boolean indicating if animations are enabled
  39309. */
  39310. animationsEnabled: boolean;
  39311. private _animationPropertiesOverride;
  39312. /**
  39313. * Gets or sets the animation properties override
  39314. */
  39315. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39316. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39317. /**
  39318. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39319. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39320. */
  39321. useConstantAnimationDeltaTime: boolean;
  39322. /**
  39323. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39324. * Please note that it requires to run a ray cast through the scene on every frame
  39325. */
  39326. constantlyUpdateMeshUnderPointer: boolean;
  39327. /**
  39328. * Defines the HTML cursor to use when hovering over interactive elements
  39329. */
  39330. hoverCursor: string;
  39331. /**
  39332. * Defines the HTML default cursor to use (empty by default)
  39333. */
  39334. defaultCursor: string;
  39335. /**
  39336. * Defines whether cursors are handled by the scene.
  39337. */
  39338. doNotHandleCursors: boolean;
  39339. /**
  39340. * This is used to call preventDefault() on pointer down
  39341. * in order to block unwanted artifacts like system double clicks
  39342. */
  39343. preventDefaultOnPointerDown: boolean;
  39344. /**
  39345. * This is used to call preventDefault() on pointer up
  39346. * in order to block unwanted artifacts like system double clicks
  39347. */
  39348. preventDefaultOnPointerUp: boolean;
  39349. /**
  39350. * Gets or sets user defined metadata
  39351. */
  39352. metadata: any;
  39353. /**
  39354. * For internal use only. Please do not use.
  39355. */
  39356. reservedDataStore: any;
  39357. /**
  39358. * Gets the name of the plugin used to load this scene (null by default)
  39359. */
  39360. loadingPluginName: string;
  39361. /**
  39362. * Use this array to add regular expressions used to disable offline support for specific urls
  39363. */
  39364. disableOfflineSupportExceptionRules: RegExp[];
  39365. /**
  39366. * An event triggered when the scene is disposed.
  39367. */
  39368. onDisposeObservable: Observable<Scene>;
  39369. private _onDisposeObserver;
  39370. /** Sets a function to be executed when this scene is disposed. */
  39371. set onDispose(callback: () => void);
  39372. /**
  39373. * An event triggered before rendering the scene (right after animations and physics)
  39374. */
  39375. onBeforeRenderObservable: Observable<Scene>;
  39376. private _onBeforeRenderObserver;
  39377. /** Sets a function to be executed before rendering this scene */
  39378. set beforeRender(callback: Nullable<() => void>);
  39379. /**
  39380. * An event triggered after rendering the scene
  39381. */
  39382. onAfterRenderObservable: Observable<Scene>;
  39383. /**
  39384. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39385. */
  39386. onAfterRenderCameraObservable: Observable<Camera>;
  39387. private _onAfterRenderObserver;
  39388. /** Sets a function to be executed after rendering this scene */
  39389. set afterRender(callback: Nullable<() => void>);
  39390. /**
  39391. * An event triggered before animating the scene
  39392. */
  39393. onBeforeAnimationsObservable: Observable<Scene>;
  39394. /**
  39395. * An event triggered after animations processing
  39396. */
  39397. onAfterAnimationsObservable: Observable<Scene>;
  39398. /**
  39399. * An event triggered before draw calls are ready to be sent
  39400. */
  39401. onBeforeDrawPhaseObservable: Observable<Scene>;
  39402. /**
  39403. * An event triggered after draw calls have been sent
  39404. */
  39405. onAfterDrawPhaseObservable: Observable<Scene>;
  39406. /**
  39407. * An event triggered when the scene is ready
  39408. */
  39409. onReadyObservable: Observable<Scene>;
  39410. /**
  39411. * An event triggered before rendering a camera
  39412. */
  39413. onBeforeCameraRenderObservable: Observable<Camera>;
  39414. private _onBeforeCameraRenderObserver;
  39415. /** Sets a function to be executed before rendering a camera*/
  39416. set beforeCameraRender(callback: () => void);
  39417. /**
  39418. * An event triggered after rendering a camera
  39419. */
  39420. onAfterCameraRenderObservable: Observable<Camera>;
  39421. private _onAfterCameraRenderObserver;
  39422. /** Sets a function to be executed after rendering a camera*/
  39423. set afterCameraRender(callback: () => void);
  39424. /**
  39425. * An event triggered when active meshes evaluation is about to start
  39426. */
  39427. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39428. /**
  39429. * An event triggered when active meshes evaluation is done
  39430. */
  39431. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39432. /**
  39433. * An event triggered when particles rendering is about to start
  39434. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39435. */
  39436. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39437. /**
  39438. * An event triggered when particles rendering is done
  39439. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39440. */
  39441. onAfterParticlesRenderingObservable: Observable<Scene>;
  39442. /**
  39443. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39444. */
  39445. onDataLoadedObservable: Observable<Scene>;
  39446. /**
  39447. * An event triggered when a camera is created
  39448. */
  39449. onNewCameraAddedObservable: Observable<Camera>;
  39450. /**
  39451. * An event triggered when a camera is removed
  39452. */
  39453. onCameraRemovedObservable: Observable<Camera>;
  39454. /**
  39455. * An event triggered when a light is created
  39456. */
  39457. onNewLightAddedObservable: Observable<Light>;
  39458. /**
  39459. * An event triggered when a light is removed
  39460. */
  39461. onLightRemovedObservable: Observable<Light>;
  39462. /**
  39463. * An event triggered when a geometry is created
  39464. */
  39465. onNewGeometryAddedObservable: Observable<Geometry>;
  39466. /**
  39467. * An event triggered when a geometry is removed
  39468. */
  39469. onGeometryRemovedObservable: Observable<Geometry>;
  39470. /**
  39471. * An event triggered when a transform node is created
  39472. */
  39473. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39474. /**
  39475. * An event triggered when a transform node is removed
  39476. */
  39477. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39478. /**
  39479. * An event triggered when a mesh is created
  39480. */
  39481. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39482. /**
  39483. * An event triggered when a mesh is removed
  39484. */
  39485. onMeshRemovedObservable: Observable<AbstractMesh>;
  39486. /**
  39487. * An event triggered when a skeleton is created
  39488. */
  39489. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39490. /**
  39491. * An event triggered when a skeleton is removed
  39492. */
  39493. onSkeletonRemovedObservable: Observable<Skeleton>;
  39494. /**
  39495. * An event triggered when a material is created
  39496. */
  39497. onNewMaterialAddedObservable: Observable<Material>;
  39498. /**
  39499. * An event triggered when a material is removed
  39500. */
  39501. onMaterialRemovedObservable: Observable<Material>;
  39502. /**
  39503. * An event triggered when a texture is created
  39504. */
  39505. onNewTextureAddedObservable: Observable<BaseTexture>;
  39506. /**
  39507. * An event triggered when a texture is removed
  39508. */
  39509. onTextureRemovedObservable: Observable<BaseTexture>;
  39510. /**
  39511. * An event triggered when render targets are about to be rendered
  39512. * Can happen multiple times per frame.
  39513. */
  39514. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39515. /**
  39516. * An event triggered when render targets were rendered.
  39517. * Can happen multiple times per frame.
  39518. */
  39519. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39520. /**
  39521. * An event triggered before calculating deterministic simulation step
  39522. */
  39523. onBeforeStepObservable: Observable<Scene>;
  39524. /**
  39525. * An event triggered after calculating deterministic simulation step
  39526. */
  39527. onAfterStepObservable: Observable<Scene>;
  39528. /**
  39529. * An event triggered when the activeCamera property is updated
  39530. */
  39531. onActiveCameraChanged: Observable<Scene>;
  39532. /**
  39533. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39534. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39535. * 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)
  39536. */
  39537. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39538. /**
  39539. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39540. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39541. * 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)
  39542. */
  39543. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39544. /**
  39545. * This Observable will when a mesh has been imported into the scene.
  39546. */
  39547. onMeshImportedObservable: Observable<AbstractMesh>;
  39548. /**
  39549. * This Observable will when an animation file has been imported into the scene.
  39550. */
  39551. onAnimationFileImportedObservable: Observable<Scene>;
  39552. /**
  39553. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39554. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39555. */
  39556. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39557. /** @hidden */
  39558. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39559. /**
  39560. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39561. */
  39562. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39563. /**
  39564. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39565. */
  39566. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39567. /**
  39568. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39569. */
  39570. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39571. /** Callback called when a pointer move is detected */
  39572. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39573. /** Callback called when a pointer down is detected */
  39574. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39575. /** Callback called when a pointer up is detected */
  39576. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39577. /** Callback called when a pointer pick is detected */
  39578. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39579. /**
  39580. * 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).
  39581. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39582. */
  39583. onPrePointerObservable: Observable<PointerInfoPre>;
  39584. /**
  39585. * Observable event triggered each time an input event is received from the rendering canvas
  39586. */
  39587. onPointerObservable: Observable<PointerInfo>;
  39588. /**
  39589. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39590. */
  39591. get unTranslatedPointer(): Vector2;
  39592. /**
  39593. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39594. */
  39595. static get DragMovementThreshold(): number;
  39596. static set DragMovementThreshold(value: number);
  39597. /**
  39598. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39599. */
  39600. static get LongPressDelay(): number;
  39601. static set LongPressDelay(value: number);
  39602. /**
  39603. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39604. */
  39605. static get DoubleClickDelay(): number;
  39606. static set DoubleClickDelay(value: number);
  39607. /** If you need to check double click without raising a single click at first click, enable this flag */
  39608. static get ExclusiveDoubleClickMode(): boolean;
  39609. static set ExclusiveDoubleClickMode(value: boolean);
  39610. /** @hidden */
  39611. _mirroredCameraPosition: Nullable<Vector3>;
  39612. /**
  39613. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39614. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39615. */
  39616. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39617. /**
  39618. * Observable event triggered each time an keyboard event is received from the hosting window
  39619. */
  39620. onKeyboardObservable: Observable<KeyboardInfo>;
  39621. private _useRightHandedSystem;
  39622. /**
  39623. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39624. */
  39625. set useRightHandedSystem(value: boolean);
  39626. get useRightHandedSystem(): boolean;
  39627. private _timeAccumulator;
  39628. private _currentStepId;
  39629. private _currentInternalStep;
  39630. /**
  39631. * Sets the step Id used by deterministic lock step
  39632. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39633. * @param newStepId defines the step Id
  39634. */
  39635. setStepId(newStepId: number): void;
  39636. /**
  39637. * Gets the step Id used by deterministic lock step
  39638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39639. * @returns the step Id
  39640. */
  39641. getStepId(): number;
  39642. /**
  39643. * Gets the internal step used by deterministic lock step
  39644. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39645. * @returns the internal step
  39646. */
  39647. getInternalStep(): number;
  39648. private _fogEnabled;
  39649. /**
  39650. * Gets or sets a boolean indicating if fog is enabled on this scene
  39651. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39652. * (Default is true)
  39653. */
  39654. set fogEnabled(value: boolean);
  39655. get fogEnabled(): boolean;
  39656. private _fogMode;
  39657. /**
  39658. * Gets or sets the fog mode to use
  39659. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39660. * | mode | value |
  39661. * | --- | --- |
  39662. * | FOGMODE_NONE | 0 |
  39663. * | FOGMODE_EXP | 1 |
  39664. * | FOGMODE_EXP2 | 2 |
  39665. * | FOGMODE_LINEAR | 3 |
  39666. */
  39667. set fogMode(value: number);
  39668. get fogMode(): number;
  39669. /**
  39670. * Gets or sets the fog color to use
  39671. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39672. * (Default is Color3(0.2, 0.2, 0.3))
  39673. */
  39674. fogColor: Color3;
  39675. /**
  39676. * Gets or sets the fog density to use
  39677. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39678. * (Default is 0.1)
  39679. */
  39680. fogDensity: number;
  39681. /**
  39682. * Gets or sets the fog start distance to use
  39683. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39684. * (Default is 0)
  39685. */
  39686. fogStart: number;
  39687. /**
  39688. * Gets or sets the fog end distance to use
  39689. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39690. * (Default is 1000)
  39691. */
  39692. fogEnd: number;
  39693. /**
  39694. * Flag indicating that the frame buffer binding is handled by another component
  39695. */
  39696. prePass: boolean;
  39697. private _shadowsEnabled;
  39698. /**
  39699. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39700. */
  39701. set shadowsEnabled(value: boolean);
  39702. get shadowsEnabled(): boolean;
  39703. private _lightsEnabled;
  39704. /**
  39705. * Gets or sets a boolean indicating if lights are enabled on this scene
  39706. */
  39707. set lightsEnabled(value: boolean);
  39708. get lightsEnabled(): boolean;
  39709. /** All of the active cameras added to this scene. */
  39710. activeCameras: Camera[];
  39711. /** @hidden */
  39712. _activeCamera: Nullable<Camera>;
  39713. /** Gets or sets the current active camera */
  39714. get activeCamera(): Nullable<Camera>;
  39715. set activeCamera(value: Nullable<Camera>);
  39716. private _defaultMaterial;
  39717. /** The default material used on meshes when no material is affected */
  39718. get defaultMaterial(): Material;
  39719. /** The default material used on meshes when no material is affected */
  39720. set defaultMaterial(value: Material);
  39721. private _texturesEnabled;
  39722. /**
  39723. * Gets or sets a boolean indicating if textures are enabled on this scene
  39724. */
  39725. set texturesEnabled(value: boolean);
  39726. get texturesEnabled(): boolean;
  39727. /**
  39728. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39729. */
  39730. physicsEnabled: boolean;
  39731. /**
  39732. * Gets or sets a boolean indicating if particles are enabled on this scene
  39733. */
  39734. particlesEnabled: boolean;
  39735. /**
  39736. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39737. */
  39738. spritesEnabled: boolean;
  39739. private _skeletonsEnabled;
  39740. /**
  39741. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39742. */
  39743. set skeletonsEnabled(value: boolean);
  39744. get skeletonsEnabled(): boolean;
  39745. /**
  39746. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39747. */
  39748. lensFlaresEnabled: boolean;
  39749. /**
  39750. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39751. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39752. */
  39753. collisionsEnabled: boolean;
  39754. private _collisionCoordinator;
  39755. /** @hidden */
  39756. get collisionCoordinator(): ICollisionCoordinator;
  39757. /**
  39758. * Defines the gravity applied to this scene (used only for collisions)
  39759. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39760. */
  39761. gravity: Vector3;
  39762. /**
  39763. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39764. */
  39765. postProcessesEnabled: boolean;
  39766. /**
  39767. * The list of postprocesses added to the scene
  39768. */
  39769. postProcesses: PostProcess[];
  39770. /**
  39771. * Gets the current postprocess manager
  39772. */
  39773. postProcessManager: PostProcessManager;
  39774. /**
  39775. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39776. */
  39777. renderTargetsEnabled: boolean;
  39778. /**
  39779. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39780. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39781. */
  39782. dumpNextRenderTargets: boolean;
  39783. /**
  39784. * The list of user defined render targets added to the scene
  39785. */
  39786. customRenderTargets: RenderTargetTexture[];
  39787. /**
  39788. * Defines if texture loading must be delayed
  39789. * If true, textures will only be loaded when they need to be rendered
  39790. */
  39791. useDelayedTextureLoading: boolean;
  39792. /**
  39793. * Gets the list of meshes imported to the scene through SceneLoader
  39794. */
  39795. importedMeshesFiles: String[];
  39796. /**
  39797. * Gets or sets a boolean indicating if probes are enabled on this scene
  39798. */
  39799. probesEnabled: boolean;
  39800. /**
  39801. * Gets or sets the current offline provider to use to store scene data
  39802. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39803. */
  39804. offlineProvider: IOfflineProvider;
  39805. /**
  39806. * Gets or sets the action manager associated with the scene
  39807. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39808. */
  39809. actionManager: AbstractActionManager;
  39810. private _meshesForIntersections;
  39811. /**
  39812. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39813. */
  39814. proceduralTexturesEnabled: boolean;
  39815. private _engine;
  39816. private _totalVertices;
  39817. /** @hidden */
  39818. _activeIndices: PerfCounter;
  39819. /** @hidden */
  39820. _activeParticles: PerfCounter;
  39821. /** @hidden */
  39822. _activeBones: PerfCounter;
  39823. private _animationRatio;
  39824. /** @hidden */
  39825. _animationTimeLast: number;
  39826. /** @hidden */
  39827. _animationTime: number;
  39828. /**
  39829. * Gets or sets a general scale for animation speed
  39830. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39831. */
  39832. animationTimeScale: number;
  39833. /** @hidden */
  39834. _cachedMaterial: Nullable<Material>;
  39835. /** @hidden */
  39836. _cachedEffect: Nullable<Effect>;
  39837. /** @hidden */
  39838. _cachedVisibility: Nullable<number>;
  39839. private _renderId;
  39840. private _frameId;
  39841. private _executeWhenReadyTimeoutId;
  39842. private _intermediateRendering;
  39843. private _viewUpdateFlag;
  39844. private _projectionUpdateFlag;
  39845. /** @hidden */
  39846. _toBeDisposed: Nullable<IDisposable>[];
  39847. private _activeRequests;
  39848. /** @hidden */
  39849. _pendingData: any[];
  39850. private _isDisposed;
  39851. /**
  39852. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39853. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39854. */
  39855. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39856. private _activeMeshes;
  39857. private _processedMaterials;
  39858. private _renderTargets;
  39859. /** @hidden */
  39860. _activeParticleSystems: SmartArray<IParticleSystem>;
  39861. private _activeSkeletons;
  39862. private _softwareSkinnedMeshes;
  39863. private _renderingManager;
  39864. /** @hidden */
  39865. _activeAnimatables: Animatable[];
  39866. private _transformMatrix;
  39867. private _sceneUbo;
  39868. /** @hidden */
  39869. _viewMatrix: Matrix;
  39870. private _projectionMatrix;
  39871. /** @hidden */
  39872. _forcedViewPosition: Nullable<Vector3>;
  39873. /** @hidden */
  39874. _frustumPlanes: Plane[];
  39875. /**
  39876. * Gets the list of frustum planes (built from the active camera)
  39877. */
  39878. get frustumPlanes(): Plane[];
  39879. /**
  39880. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39881. * This is useful if there are more lights that the maximum simulteanous authorized
  39882. */
  39883. requireLightSorting: boolean;
  39884. /** @hidden */
  39885. readonly useMaterialMeshMap: boolean;
  39886. /** @hidden */
  39887. readonly useClonedMeshMap: boolean;
  39888. private _externalData;
  39889. private _uid;
  39890. /**
  39891. * @hidden
  39892. * Backing store of defined scene components.
  39893. */
  39894. _components: ISceneComponent[];
  39895. /**
  39896. * @hidden
  39897. * Backing store of defined scene components.
  39898. */
  39899. _serializableComponents: ISceneSerializableComponent[];
  39900. /**
  39901. * List of components to register on the next registration step.
  39902. */
  39903. private _transientComponents;
  39904. /**
  39905. * Registers the transient components if needed.
  39906. */
  39907. private _registerTransientComponents;
  39908. /**
  39909. * @hidden
  39910. * Add a component to the scene.
  39911. * Note that the ccomponent could be registered on th next frame if this is called after
  39912. * the register component stage.
  39913. * @param component Defines the component to add to the scene
  39914. */
  39915. _addComponent(component: ISceneComponent): void;
  39916. /**
  39917. * @hidden
  39918. * Gets a component from the scene.
  39919. * @param name defines the name of the component to retrieve
  39920. * @returns the component or null if not present
  39921. */
  39922. _getComponent(name: string): Nullable<ISceneComponent>;
  39923. /**
  39924. * @hidden
  39925. * Defines the actions happening before camera updates.
  39926. */
  39927. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39928. /**
  39929. * @hidden
  39930. * Defines the actions happening before clear the canvas.
  39931. */
  39932. _beforeClearStage: Stage<SimpleStageAction>;
  39933. /**
  39934. * @hidden
  39935. * Defines the actions when collecting render targets for the frame.
  39936. */
  39937. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39938. /**
  39939. * @hidden
  39940. * Defines the actions happening for one camera in the frame.
  39941. */
  39942. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39943. /**
  39944. * @hidden
  39945. * Defines the actions happening during the per mesh ready checks.
  39946. */
  39947. _isReadyForMeshStage: Stage<MeshStageAction>;
  39948. /**
  39949. * @hidden
  39950. * Defines the actions happening before evaluate active mesh checks.
  39951. */
  39952. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39953. /**
  39954. * @hidden
  39955. * Defines the actions happening during the evaluate sub mesh checks.
  39956. */
  39957. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39958. /**
  39959. * @hidden
  39960. * Defines the actions happening during the active mesh stage.
  39961. */
  39962. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39963. /**
  39964. * @hidden
  39965. * Defines the actions happening during the per camera render target step.
  39966. */
  39967. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39968. /**
  39969. * @hidden
  39970. * Defines the actions happening just before the active camera is drawing.
  39971. */
  39972. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39973. /**
  39974. * @hidden
  39975. * Defines the actions happening just before a render target is drawing.
  39976. */
  39977. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39978. /**
  39979. * @hidden
  39980. * Defines the actions happening just before a rendering group is drawing.
  39981. */
  39982. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39983. /**
  39984. * @hidden
  39985. * Defines the actions happening just before a mesh is drawing.
  39986. */
  39987. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39988. /**
  39989. * @hidden
  39990. * Defines the actions happening just after a mesh has been drawn.
  39991. */
  39992. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39993. /**
  39994. * @hidden
  39995. * Defines the actions happening just after a rendering group has been drawn.
  39996. */
  39997. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39998. /**
  39999. * @hidden
  40000. * Defines the actions happening just after the active camera has been drawn.
  40001. */
  40002. _afterCameraDrawStage: Stage<CameraStageAction>;
  40003. /**
  40004. * @hidden
  40005. * Defines the actions happening just after a render target has been drawn.
  40006. */
  40007. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40008. /**
  40009. * @hidden
  40010. * Defines the actions happening just after rendering all cameras and computing intersections.
  40011. */
  40012. _afterRenderStage: Stage<SimpleStageAction>;
  40013. /**
  40014. * @hidden
  40015. * Defines the actions happening when a pointer move event happens.
  40016. */
  40017. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40018. /**
  40019. * @hidden
  40020. * Defines the actions happening when a pointer down event happens.
  40021. */
  40022. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40023. /**
  40024. * @hidden
  40025. * Defines the actions happening when a pointer up event happens.
  40026. */
  40027. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40028. /**
  40029. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40030. */
  40031. private geometriesByUniqueId;
  40032. /**
  40033. * Creates a new Scene
  40034. * @param engine defines the engine to use to render this scene
  40035. * @param options defines the scene options
  40036. */
  40037. constructor(engine: Engine, options?: SceneOptions);
  40038. /**
  40039. * Gets a string idenfifying the name of the class
  40040. * @returns "Scene" string
  40041. */
  40042. getClassName(): string;
  40043. private _defaultMeshCandidates;
  40044. /**
  40045. * @hidden
  40046. */
  40047. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40048. private _defaultSubMeshCandidates;
  40049. /**
  40050. * @hidden
  40051. */
  40052. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40053. /**
  40054. * Sets the default candidate providers for the scene.
  40055. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40056. * and getCollidingSubMeshCandidates to their default function
  40057. */
  40058. setDefaultCandidateProviders(): void;
  40059. /**
  40060. * Gets the mesh that is currently under the pointer
  40061. */
  40062. get meshUnderPointer(): Nullable<AbstractMesh>;
  40063. /**
  40064. * Gets or sets the current on-screen X position of the pointer
  40065. */
  40066. get pointerX(): number;
  40067. set pointerX(value: number);
  40068. /**
  40069. * Gets or sets the current on-screen Y position of the pointer
  40070. */
  40071. get pointerY(): number;
  40072. set pointerY(value: number);
  40073. /**
  40074. * Gets the cached material (ie. the latest rendered one)
  40075. * @returns the cached material
  40076. */
  40077. getCachedMaterial(): Nullable<Material>;
  40078. /**
  40079. * Gets the cached effect (ie. the latest rendered one)
  40080. * @returns the cached effect
  40081. */
  40082. getCachedEffect(): Nullable<Effect>;
  40083. /**
  40084. * Gets the cached visibility state (ie. the latest rendered one)
  40085. * @returns the cached visibility state
  40086. */
  40087. getCachedVisibility(): Nullable<number>;
  40088. /**
  40089. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40090. * @param material defines the current material
  40091. * @param effect defines the current effect
  40092. * @param visibility defines the current visibility state
  40093. * @returns true if one parameter is not cached
  40094. */
  40095. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40096. /**
  40097. * Gets the engine associated with the scene
  40098. * @returns an Engine
  40099. */
  40100. getEngine(): Engine;
  40101. /**
  40102. * Gets the total number of vertices rendered per frame
  40103. * @returns the total number of vertices rendered per frame
  40104. */
  40105. getTotalVertices(): number;
  40106. /**
  40107. * Gets the performance counter for total vertices
  40108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40109. */
  40110. get totalVerticesPerfCounter(): PerfCounter;
  40111. /**
  40112. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40113. * @returns the total number of active indices rendered per frame
  40114. */
  40115. getActiveIndices(): number;
  40116. /**
  40117. * Gets the performance counter for active indices
  40118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40119. */
  40120. get totalActiveIndicesPerfCounter(): PerfCounter;
  40121. /**
  40122. * Gets the total number of active particles rendered per frame
  40123. * @returns the total number of active particles rendered per frame
  40124. */
  40125. getActiveParticles(): number;
  40126. /**
  40127. * Gets the performance counter for active particles
  40128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40129. */
  40130. get activeParticlesPerfCounter(): PerfCounter;
  40131. /**
  40132. * Gets the total number of active bones rendered per frame
  40133. * @returns the total number of active bones rendered per frame
  40134. */
  40135. getActiveBones(): number;
  40136. /**
  40137. * Gets the performance counter for active bones
  40138. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40139. */
  40140. get activeBonesPerfCounter(): PerfCounter;
  40141. /**
  40142. * Gets the array of active meshes
  40143. * @returns an array of AbstractMesh
  40144. */
  40145. getActiveMeshes(): SmartArray<AbstractMesh>;
  40146. /**
  40147. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40148. * @returns a number
  40149. */
  40150. getAnimationRatio(): number;
  40151. /**
  40152. * Gets an unique Id for the current render phase
  40153. * @returns a number
  40154. */
  40155. getRenderId(): number;
  40156. /**
  40157. * Gets an unique Id for the current frame
  40158. * @returns a number
  40159. */
  40160. getFrameId(): number;
  40161. /** Call this function if you want to manually increment the render Id*/
  40162. incrementRenderId(): void;
  40163. private _createUbo;
  40164. /**
  40165. * Use this method to simulate a pointer move on a mesh
  40166. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40167. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40168. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40169. * @returns the current scene
  40170. */
  40171. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40172. /**
  40173. * Use this method to simulate a pointer down on a mesh
  40174. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40175. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40176. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40177. * @returns the current scene
  40178. */
  40179. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40180. /**
  40181. * Use this method to simulate a pointer up on a mesh
  40182. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40183. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40184. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40185. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40186. * @returns the current scene
  40187. */
  40188. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40189. /**
  40190. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40191. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40192. * @returns true if the pointer was captured
  40193. */
  40194. isPointerCaptured(pointerId?: number): boolean;
  40195. /**
  40196. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40197. * @param attachUp defines if you want to attach events to pointerup
  40198. * @param attachDown defines if you want to attach events to pointerdown
  40199. * @param attachMove defines if you want to attach events to pointermove
  40200. */
  40201. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40202. /** Detaches all event handlers*/
  40203. detachControl(): void;
  40204. /**
  40205. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40206. * Delay loaded resources are not taking in account
  40207. * @return true if all required resources are ready
  40208. */
  40209. isReady(): boolean;
  40210. /** Resets all cached information relative to material (including effect and visibility) */
  40211. resetCachedMaterial(): void;
  40212. /**
  40213. * Registers a function to be called before every frame render
  40214. * @param func defines the function to register
  40215. */
  40216. registerBeforeRender(func: () => void): void;
  40217. /**
  40218. * Unregisters a function called before every frame render
  40219. * @param func defines the function to unregister
  40220. */
  40221. unregisterBeforeRender(func: () => void): void;
  40222. /**
  40223. * Registers a function to be called after every frame render
  40224. * @param func defines the function to register
  40225. */
  40226. registerAfterRender(func: () => void): void;
  40227. /**
  40228. * Unregisters a function called after every frame render
  40229. * @param func defines the function to unregister
  40230. */
  40231. unregisterAfterRender(func: () => void): void;
  40232. private _executeOnceBeforeRender;
  40233. /**
  40234. * The provided function will run before render once and will be disposed afterwards.
  40235. * A timeout delay can be provided so that the function will be executed in N ms.
  40236. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40237. * @param func The function to be executed.
  40238. * @param timeout optional delay in ms
  40239. */
  40240. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40241. /** @hidden */
  40242. _addPendingData(data: any): void;
  40243. /** @hidden */
  40244. _removePendingData(data: any): void;
  40245. /**
  40246. * Returns the number of items waiting to be loaded
  40247. * @returns the number of items waiting to be loaded
  40248. */
  40249. getWaitingItemsCount(): number;
  40250. /**
  40251. * Returns a boolean indicating if the scene is still loading data
  40252. */
  40253. get isLoading(): boolean;
  40254. /**
  40255. * Registers a function to be executed when the scene is ready
  40256. * @param {Function} func - the function to be executed
  40257. */
  40258. executeWhenReady(func: () => void): void;
  40259. /**
  40260. * Returns a promise that resolves when the scene is ready
  40261. * @returns A promise that resolves when the scene is ready
  40262. */
  40263. whenReadyAsync(): Promise<void>;
  40264. /** @hidden */
  40265. _checkIsReady(): void;
  40266. /**
  40267. * Gets all animatable attached to the scene
  40268. */
  40269. get animatables(): Animatable[];
  40270. /**
  40271. * Resets the last animation time frame.
  40272. * Useful to override when animations start running when loading a scene for the first time.
  40273. */
  40274. resetLastAnimationTimeFrame(): void;
  40275. /**
  40276. * Gets the current view matrix
  40277. * @returns a Matrix
  40278. */
  40279. getViewMatrix(): Matrix;
  40280. /**
  40281. * Gets the current projection matrix
  40282. * @returns a Matrix
  40283. */
  40284. getProjectionMatrix(): Matrix;
  40285. /**
  40286. * Gets the current transform matrix
  40287. * @returns a Matrix made of View * Projection
  40288. */
  40289. getTransformMatrix(): Matrix;
  40290. /**
  40291. * Sets the current transform matrix
  40292. * @param viewL defines the View matrix to use
  40293. * @param projectionL defines the Projection matrix to use
  40294. * @param viewR defines the right View matrix to use (if provided)
  40295. * @param projectionR defines the right Projection matrix to use (if provided)
  40296. */
  40297. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40298. /**
  40299. * Gets the uniform buffer used to store scene data
  40300. * @returns a UniformBuffer
  40301. */
  40302. getSceneUniformBuffer(): UniformBuffer;
  40303. /**
  40304. * Gets an unique (relatively to the current scene) Id
  40305. * @returns an unique number for the scene
  40306. */
  40307. getUniqueId(): number;
  40308. /**
  40309. * Add a mesh to the list of scene's meshes
  40310. * @param newMesh defines the mesh to add
  40311. * @param recursive if all child meshes should also be added to the scene
  40312. */
  40313. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40314. /**
  40315. * Remove a mesh for the list of scene's meshes
  40316. * @param toRemove defines the mesh to remove
  40317. * @param recursive if all child meshes should also be removed from the scene
  40318. * @returns the index where the mesh was in the mesh list
  40319. */
  40320. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40321. /**
  40322. * Add a transform node to the list of scene's transform nodes
  40323. * @param newTransformNode defines the transform node to add
  40324. */
  40325. addTransformNode(newTransformNode: TransformNode): void;
  40326. /**
  40327. * Remove a transform node for the list of scene's transform nodes
  40328. * @param toRemove defines the transform node to remove
  40329. * @returns the index where the transform node was in the transform node list
  40330. */
  40331. removeTransformNode(toRemove: TransformNode): number;
  40332. /**
  40333. * Remove a skeleton for the list of scene's skeletons
  40334. * @param toRemove defines the skeleton to remove
  40335. * @returns the index where the skeleton was in the skeleton list
  40336. */
  40337. removeSkeleton(toRemove: Skeleton): number;
  40338. /**
  40339. * Remove a morph target for the list of scene's morph targets
  40340. * @param toRemove defines the morph target to remove
  40341. * @returns the index where the morph target was in the morph target list
  40342. */
  40343. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40344. /**
  40345. * Remove a light for the list of scene's lights
  40346. * @param toRemove defines the light to remove
  40347. * @returns the index where the light was in the light list
  40348. */
  40349. removeLight(toRemove: Light): number;
  40350. /**
  40351. * Remove a camera for the list of scene's cameras
  40352. * @param toRemove defines the camera to remove
  40353. * @returns the index where the camera was in the camera list
  40354. */
  40355. removeCamera(toRemove: Camera): number;
  40356. /**
  40357. * Remove a particle system for the list of scene's particle systems
  40358. * @param toRemove defines the particle system to remove
  40359. * @returns the index where the particle system was in the particle system list
  40360. */
  40361. removeParticleSystem(toRemove: IParticleSystem): number;
  40362. /**
  40363. * Remove a animation for the list of scene's animations
  40364. * @param toRemove defines the animation to remove
  40365. * @returns the index where the animation was in the animation list
  40366. */
  40367. removeAnimation(toRemove: Animation): number;
  40368. /**
  40369. * Will stop the animation of the given target
  40370. * @param target - the target
  40371. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40372. * @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)
  40373. */
  40374. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40375. /**
  40376. * Removes the given animation group from this scene.
  40377. * @param toRemove The animation group to remove
  40378. * @returns The index of the removed animation group
  40379. */
  40380. removeAnimationGroup(toRemove: AnimationGroup): number;
  40381. /**
  40382. * Removes the given multi-material from this scene.
  40383. * @param toRemove The multi-material to remove
  40384. * @returns The index of the removed multi-material
  40385. */
  40386. removeMultiMaterial(toRemove: MultiMaterial): number;
  40387. /**
  40388. * Removes the given material from this scene.
  40389. * @param toRemove The material to remove
  40390. * @returns The index of the removed material
  40391. */
  40392. removeMaterial(toRemove: Material): number;
  40393. /**
  40394. * Removes the given action manager from this scene.
  40395. * @param toRemove The action manager to remove
  40396. * @returns The index of the removed action manager
  40397. */
  40398. removeActionManager(toRemove: AbstractActionManager): number;
  40399. /**
  40400. * Removes the given texture from this scene.
  40401. * @param toRemove The texture to remove
  40402. * @returns The index of the removed texture
  40403. */
  40404. removeTexture(toRemove: BaseTexture): number;
  40405. /**
  40406. * Adds the given light to this scene
  40407. * @param newLight The light to add
  40408. */
  40409. addLight(newLight: Light): void;
  40410. /**
  40411. * Sorts the list list based on light priorities
  40412. */
  40413. sortLightsByPriority(): void;
  40414. /**
  40415. * Adds the given camera to this scene
  40416. * @param newCamera The camera to add
  40417. */
  40418. addCamera(newCamera: Camera): void;
  40419. /**
  40420. * Adds the given skeleton to this scene
  40421. * @param newSkeleton The skeleton to add
  40422. */
  40423. addSkeleton(newSkeleton: Skeleton): void;
  40424. /**
  40425. * Adds the given particle system to this scene
  40426. * @param newParticleSystem The particle system to add
  40427. */
  40428. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40429. /**
  40430. * Adds the given animation to this scene
  40431. * @param newAnimation The animation to add
  40432. */
  40433. addAnimation(newAnimation: Animation): void;
  40434. /**
  40435. * Adds the given animation group to this scene.
  40436. * @param newAnimationGroup The animation group to add
  40437. */
  40438. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40439. /**
  40440. * Adds the given multi-material to this scene
  40441. * @param newMultiMaterial The multi-material to add
  40442. */
  40443. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40444. /**
  40445. * Adds the given material to this scene
  40446. * @param newMaterial The material to add
  40447. */
  40448. addMaterial(newMaterial: Material): void;
  40449. /**
  40450. * Adds the given morph target to this scene
  40451. * @param newMorphTargetManager The morph target to add
  40452. */
  40453. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40454. /**
  40455. * Adds the given geometry to this scene
  40456. * @param newGeometry The geometry to add
  40457. */
  40458. addGeometry(newGeometry: Geometry): void;
  40459. /**
  40460. * Adds the given action manager to this scene
  40461. * @param newActionManager The action manager to add
  40462. */
  40463. addActionManager(newActionManager: AbstractActionManager): void;
  40464. /**
  40465. * Adds the given texture to this scene.
  40466. * @param newTexture The texture to add
  40467. */
  40468. addTexture(newTexture: BaseTexture): void;
  40469. /**
  40470. * Switch active camera
  40471. * @param newCamera defines the new active camera
  40472. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40473. */
  40474. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40475. /**
  40476. * sets the active camera of the scene using its ID
  40477. * @param id defines the camera's ID
  40478. * @return the new active camera or null if none found.
  40479. */
  40480. setActiveCameraByID(id: string): Nullable<Camera>;
  40481. /**
  40482. * sets the active camera of the scene using its name
  40483. * @param name defines the camera's name
  40484. * @returns the new active camera or null if none found.
  40485. */
  40486. setActiveCameraByName(name: string): Nullable<Camera>;
  40487. /**
  40488. * get an animation group using its name
  40489. * @param name defines the material's name
  40490. * @return the animation group or null if none found.
  40491. */
  40492. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40493. /**
  40494. * Get a material using its unique id
  40495. * @param uniqueId defines the material's unique id
  40496. * @return the material or null if none found.
  40497. */
  40498. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40499. /**
  40500. * get a material using its id
  40501. * @param id defines the material's ID
  40502. * @return the material or null if none found.
  40503. */
  40504. getMaterialByID(id: string): Nullable<Material>;
  40505. /**
  40506. * Gets a the last added material using a given id
  40507. * @param id defines the material's ID
  40508. * @return the last material with the given id or null if none found.
  40509. */
  40510. getLastMaterialByID(id: string): Nullable<Material>;
  40511. /**
  40512. * Gets a material using its name
  40513. * @param name defines the material's name
  40514. * @return the material or null if none found.
  40515. */
  40516. getMaterialByName(name: string): Nullable<Material>;
  40517. /**
  40518. * Get a texture using its unique id
  40519. * @param uniqueId defines the texture's unique id
  40520. * @return the texture or null if none found.
  40521. */
  40522. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40523. /**
  40524. * Gets a camera using its id
  40525. * @param id defines the id to look for
  40526. * @returns the camera or null if not found
  40527. */
  40528. getCameraByID(id: string): Nullable<Camera>;
  40529. /**
  40530. * Gets a camera using its unique id
  40531. * @param uniqueId defines the unique id to look for
  40532. * @returns the camera or null if not found
  40533. */
  40534. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40535. /**
  40536. * Gets a camera using its name
  40537. * @param name defines the camera's name
  40538. * @return the camera or null if none found.
  40539. */
  40540. getCameraByName(name: string): Nullable<Camera>;
  40541. /**
  40542. * Gets a bone using its id
  40543. * @param id defines the bone's id
  40544. * @return the bone or null if not found
  40545. */
  40546. getBoneByID(id: string): Nullable<Bone>;
  40547. /**
  40548. * Gets a bone using its id
  40549. * @param name defines the bone's name
  40550. * @return the bone or null if not found
  40551. */
  40552. getBoneByName(name: string): Nullable<Bone>;
  40553. /**
  40554. * Gets a light node using its name
  40555. * @param name defines the the light's name
  40556. * @return the light or null if none found.
  40557. */
  40558. getLightByName(name: string): Nullable<Light>;
  40559. /**
  40560. * Gets a light node using its id
  40561. * @param id defines the light's id
  40562. * @return the light or null if none found.
  40563. */
  40564. getLightByID(id: string): Nullable<Light>;
  40565. /**
  40566. * Gets a light node using its scene-generated unique ID
  40567. * @param uniqueId defines the light's unique id
  40568. * @return the light or null if none found.
  40569. */
  40570. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40571. /**
  40572. * Gets a particle system by id
  40573. * @param id defines the particle system id
  40574. * @return the corresponding system or null if none found
  40575. */
  40576. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40577. /**
  40578. * Gets a geometry using its ID
  40579. * @param id defines the geometry's id
  40580. * @return the geometry or null if none found.
  40581. */
  40582. getGeometryByID(id: string): Nullable<Geometry>;
  40583. private _getGeometryByUniqueID;
  40584. /**
  40585. * Add a new geometry to this scene
  40586. * @param geometry defines the geometry to be added to the scene.
  40587. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40588. * @return a boolean defining if the geometry was added or not
  40589. */
  40590. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40591. /**
  40592. * Removes an existing geometry
  40593. * @param geometry defines the geometry to be removed from the scene
  40594. * @return a boolean defining if the geometry was removed or not
  40595. */
  40596. removeGeometry(geometry: Geometry): boolean;
  40597. /**
  40598. * Gets the list of geometries attached to the scene
  40599. * @returns an array of Geometry
  40600. */
  40601. getGeometries(): Geometry[];
  40602. /**
  40603. * Gets the first added mesh found of a given ID
  40604. * @param id defines the id to search for
  40605. * @return the mesh found or null if not found at all
  40606. */
  40607. getMeshByID(id: string): Nullable<AbstractMesh>;
  40608. /**
  40609. * Gets a list of meshes using their id
  40610. * @param id defines the id to search for
  40611. * @returns a list of meshes
  40612. */
  40613. getMeshesByID(id: string): Array<AbstractMesh>;
  40614. /**
  40615. * Gets the first added transform node found of a given ID
  40616. * @param id defines the id to search for
  40617. * @return the found transform node or null if not found at all.
  40618. */
  40619. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40620. /**
  40621. * Gets a transform node with its auto-generated unique id
  40622. * @param uniqueId efines the unique id to search for
  40623. * @return the found transform node or null if not found at all.
  40624. */
  40625. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40626. /**
  40627. * Gets a list of transform nodes using their id
  40628. * @param id defines the id to search for
  40629. * @returns a list of transform nodes
  40630. */
  40631. getTransformNodesByID(id: string): Array<TransformNode>;
  40632. /**
  40633. * Gets a mesh with its auto-generated unique id
  40634. * @param uniqueId defines the unique id to search for
  40635. * @return the found mesh or null if not found at all.
  40636. */
  40637. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40638. /**
  40639. * Gets a the last added mesh using a given id
  40640. * @param id defines the id to search for
  40641. * @return the found mesh or null if not found at all.
  40642. */
  40643. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40644. /**
  40645. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40646. * @param id defines the id to search for
  40647. * @return the found node or null if not found at all
  40648. */
  40649. getLastEntryByID(id: string): Nullable<Node>;
  40650. /**
  40651. * Gets a node (Mesh, Camera, Light) using a given id
  40652. * @param id defines the id to search for
  40653. * @return the found node or null if not found at all
  40654. */
  40655. getNodeByID(id: string): Nullable<Node>;
  40656. /**
  40657. * Gets a node (Mesh, Camera, Light) using a given name
  40658. * @param name defines the name to search for
  40659. * @return the found node or null if not found at all.
  40660. */
  40661. getNodeByName(name: string): Nullable<Node>;
  40662. /**
  40663. * Gets a mesh using a given name
  40664. * @param name defines the name to search for
  40665. * @return the found mesh or null if not found at all.
  40666. */
  40667. getMeshByName(name: string): Nullable<AbstractMesh>;
  40668. /**
  40669. * Gets a transform node using a given name
  40670. * @param name defines the name to search for
  40671. * @return the found transform node or null if not found at all.
  40672. */
  40673. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40674. /**
  40675. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40676. * @param id defines the id to search for
  40677. * @return the found skeleton or null if not found at all.
  40678. */
  40679. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40680. /**
  40681. * Gets a skeleton using a given auto generated unique id
  40682. * @param uniqueId defines the unique id to search for
  40683. * @return the found skeleton or null if not found at all.
  40684. */
  40685. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40686. /**
  40687. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40688. * @param id defines the id to search for
  40689. * @return the found skeleton or null if not found at all.
  40690. */
  40691. getSkeletonById(id: string): Nullable<Skeleton>;
  40692. /**
  40693. * Gets a skeleton using a given name
  40694. * @param name defines the name to search for
  40695. * @return the found skeleton or null if not found at all.
  40696. */
  40697. getSkeletonByName(name: string): Nullable<Skeleton>;
  40698. /**
  40699. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40700. * @param id defines the id to search for
  40701. * @return the found morph target manager or null if not found at all.
  40702. */
  40703. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40704. /**
  40705. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40706. * @param id defines the id to search for
  40707. * @return the found morph target or null if not found at all.
  40708. */
  40709. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40710. /**
  40711. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40712. * @param name defines the name to search for
  40713. * @return the found morph target or null if not found at all.
  40714. */
  40715. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40716. /**
  40717. * Gets a boolean indicating if the given mesh is active
  40718. * @param mesh defines the mesh to look for
  40719. * @returns true if the mesh is in the active list
  40720. */
  40721. isActiveMesh(mesh: AbstractMesh): boolean;
  40722. /**
  40723. * Return a unique id as a string which can serve as an identifier for the scene
  40724. */
  40725. get uid(): string;
  40726. /**
  40727. * Add an externaly attached data from its key.
  40728. * This method call will fail and return false, if such key already exists.
  40729. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40730. * @param key the unique key that identifies the data
  40731. * @param data the data object to associate to the key for this Engine instance
  40732. * @return true if no such key were already present and the data was added successfully, false otherwise
  40733. */
  40734. addExternalData<T>(key: string, data: T): boolean;
  40735. /**
  40736. * Get an externaly attached data from its key
  40737. * @param key the unique key that identifies the data
  40738. * @return the associated data, if present (can be null), or undefined if not present
  40739. */
  40740. getExternalData<T>(key: string): Nullable<T>;
  40741. /**
  40742. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40743. * @param key the unique key that identifies the data
  40744. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40745. * @return the associated data, can be null if the factory returned null.
  40746. */
  40747. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40748. /**
  40749. * Remove an externaly attached data from the Engine instance
  40750. * @param key the unique key that identifies the data
  40751. * @return true if the data was successfully removed, false if it doesn't exist
  40752. */
  40753. removeExternalData(key: string): boolean;
  40754. private _evaluateSubMesh;
  40755. /**
  40756. * Clear the processed materials smart array preventing retention point in material dispose.
  40757. */
  40758. freeProcessedMaterials(): void;
  40759. private _preventFreeActiveMeshesAndRenderingGroups;
  40760. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40761. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40762. * when disposing several meshes in a row or a hierarchy of meshes.
  40763. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40764. */
  40765. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40766. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40767. /**
  40768. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40769. */
  40770. freeActiveMeshes(): void;
  40771. /**
  40772. * Clear the info related to rendering groups preventing retention points during dispose.
  40773. */
  40774. freeRenderingGroups(): void;
  40775. /** @hidden */
  40776. _isInIntermediateRendering(): boolean;
  40777. /**
  40778. * Lambda returning the list of potentially active meshes.
  40779. */
  40780. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40781. /**
  40782. * Lambda returning the list of potentially active sub meshes.
  40783. */
  40784. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40785. /**
  40786. * Lambda returning the list of potentially intersecting sub meshes.
  40787. */
  40788. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40789. /**
  40790. * Lambda returning the list of potentially colliding sub meshes.
  40791. */
  40792. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40793. private _activeMeshesFrozen;
  40794. private _skipEvaluateActiveMeshesCompletely;
  40795. /**
  40796. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40797. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40798. * @returns the current scene
  40799. */
  40800. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40801. /**
  40802. * Use this function to restart evaluating active meshes on every frame
  40803. * @returns the current scene
  40804. */
  40805. unfreezeActiveMeshes(): Scene;
  40806. private _evaluateActiveMeshes;
  40807. private _activeMesh;
  40808. /**
  40809. * Update the transform matrix to update from the current active camera
  40810. * @param force defines a boolean used to force the update even if cache is up to date
  40811. */
  40812. updateTransformMatrix(force?: boolean): void;
  40813. private _bindFrameBuffer;
  40814. /** @hidden */
  40815. _allowPostProcessClearColor: boolean;
  40816. /** @hidden */
  40817. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40818. private _processSubCameras;
  40819. private _checkIntersections;
  40820. /** @hidden */
  40821. _advancePhysicsEngineStep(step: number): void;
  40822. /**
  40823. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40824. */
  40825. getDeterministicFrameTime: () => number;
  40826. /** @hidden */
  40827. _animate(): void;
  40828. /** Execute all animations (for a frame) */
  40829. animate(): void;
  40830. /**
  40831. * Render the scene
  40832. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40833. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40834. */
  40835. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40836. /**
  40837. * Freeze all materials
  40838. * A frozen material will not be updatable but should be faster to render
  40839. */
  40840. freezeMaterials(): void;
  40841. /**
  40842. * Unfreeze all materials
  40843. * A frozen material will not be updatable but should be faster to render
  40844. */
  40845. unfreezeMaterials(): void;
  40846. /**
  40847. * Releases all held ressources
  40848. */
  40849. dispose(): void;
  40850. /**
  40851. * Gets if the scene is already disposed
  40852. */
  40853. get isDisposed(): boolean;
  40854. /**
  40855. * Call this function to reduce memory footprint of the scene.
  40856. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40857. */
  40858. clearCachedVertexData(): void;
  40859. /**
  40860. * This function will remove the local cached buffer data from texture.
  40861. * It will save memory but will prevent the texture from being rebuilt
  40862. */
  40863. cleanCachedTextureBuffer(): void;
  40864. /**
  40865. * Get the world extend vectors with an optional filter
  40866. *
  40867. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40868. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40869. */
  40870. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40871. min: Vector3;
  40872. max: Vector3;
  40873. };
  40874. /**
  40875. * Creates a ray that can be used to pick in the scene
  40876. * @param x defines the x coordinate of the origin (on-screen)
  40877. * @param y defines the y coordinate of the origin (on-screen)
  40878. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40879. * @param camera defines the camera to use for the picking
  40880. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40881. * @returns a Ray
  40882. */
  40883. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40884. /**
  40885. * Creates a ray that can be used to pick in the scene
  40886. * @param x defines the x coordinate of the origin (on-screen)
  40887. * @param y defines the y coordinate of the origin (on-screen)
  40888. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40889. * @param result defines the ray where to store the picking ray
  40890. * @param camera defines the camera to use for the picking
  40891. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40892. * @returns the current scene
  40893. */
  40894. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40895. /**
  40896. * Creates a ray that can be used to pick in the scene
  40897. * @param x defines the x coordinate of the origin (on-screen)
  40898. * @param y defines the y coordinate of the origin (on-screen)
  40899. * @param camera defines the camera to use for the picking
  40900. * @returns a Ray
  40901. */
  40902. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40903. /**
  40904. * Creates a ray that can be used to pick in the scene
  40905. * @param x defines the x coordinate of the origin (on-screen)
  40906. * @param y defines the y coordinate of the origin (on-screen)
  40907. * @param result defines the ray where to store the picking ray
  40908. * @param camera defines the camera to use for the picking
  40909. * @returns the current scene
  40910. */
  40911. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40912. /** Launch a ray to try to pick a mesh in the scene
  40913. * @param x position on screen
  40914. * @param y position on screen
  40915. * @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
  40916. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40917. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40918. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40919. * @returns a PickingInfo
  40920. */
  40921. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40922. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40923. * @param x position on screen
  40924. * @param y position on screen
  40925. * @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
  40926. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40927. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40928. * @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)
  40929. */
  40930. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40931. /** Use the given ray to pick a mesh in the scene
  40932. * @param ray The ray to use to pick meshes
  40933. * @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
  40934. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40935. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40936. * @returns a PickingInfo
  40937. */
  40938. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40939. /**
  40940. * Launch a ray to try to pick a mesh in the scene
  40941. * @param x X position on screen
  40942. * @param y Y position on screen
  40943. * @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
  40944. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40945. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40946. * @returns an array of PickingInfo
  40947. */
  40948. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40949. /**
  40950. * Launch a ray to try to pick a mesh in the scene
  40951. * @param ray Ray to use
  40952. * @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
  40953. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40954. * @returns an array of PickingInfo
  40955. */
  40956. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40957. /**
  40958. * Force the value of meshUnderPointer
  40959. * @param mesh defines the mesh to use
  40960. */
  40961. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40962. /**
  40963. * Gets the mesh under the pointer
  40964. * @returns a Mesh or null if no mesh is under the pointer
  40965. */
  40966. getPointerOverMesh(): Nullable<AbstractMesh>;
  40967. /** @hidden */
  40968. _rebuildGeometries(): void;
  40969. /** @hidden */
  40970. _rebuildTextures(): void;
  40971. private _getByTags;
  40972. /**
  40973. * Get a list of meshes by tags
  40974. * @param tagsQuery defines the tags query to use
  40975. * @param forEach defines a predicate used to filter results
  40976. * @returns an array of Mesh
  40977. */
  40978. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40979. /**
  40980. * Get a list of cameras by tags
  40981. * @param tagsQuery defines the tags query to use
  40982. * @param forEach defines a predicate used to filter results
  40983. * @returns an array of Camera
  40984. */
  40985. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40986. /**
  40987. * Get a list of lights by tags
  40988. * @param tagsQuery defines the tags query to use
  40989. * @param forEach defines a predicate used to filter results
  40990. * @returns an array of Light
  40991. */
  40992. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40993. /**
  40994. * Get a list of materials by tags
  40995. * @param tagsQuery defines the tags query to use
  40996. * @param forEach defines a predicate used to filter results
  40997. * @returns an array of Material
  40998. */
  40999. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41000. /**
  41001. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41002. * This allowed control for front to back rendering or reversly depending of the special needs.
  41003. *
  41004. * @param renderingGroupId The rendering group id corresponding to its index
  41005. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41006. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41007. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41008. */
  41009. 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;
  41010. /**
  41011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41012. *
  41013. * @param renderingGroupId The rendering group id corresponding to its index
  41014. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41015. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41016. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41017. */
  41018. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41019. /**
  41020. * Gets the current auto clear configuration for one rendering group of the rendering
  41021. * manager.
  41022. * @param index the rendering group index to get the information for
  41023. * @returns The auto clear setup for the requested rendering group
  41024. */
  41025. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41026. private _blockMaterialDirtyMechanism;
  41027. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41028. get blockMaterialDirtyMechanism(): boolean;
  41029. set blockMaterialDirtyMechanism(value: boolean);
  41030. /**
  41031. * Will flag all materials as dirty to trigger new shader compilation
  41032. * @param flag defines the flag used to specify which material part must be marked as dirty
  41033. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41034. */
  41035. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41036. /** @hidden */
  41037. _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;
  41038. /** @hidden */
  41039. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41040. /** @hidden */
  41041. _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;
  41042. /** @hidden */
  41043. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41044. /** @hidden */
  41045. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41046. /** @hidden */
  41047. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41048. }
  41049. }
  41050. declare module BABYLON {
  41051. /**
  41052. * Set of assets to keep when moving a scene into an asset container.
  41053. */
  41054. export class KeepAssets extends AbstractScene {
  41055. }
  41056. /**
  41057. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41058. */
  41059. export class InstantiatedEntries {
  41060. /**
  41061. * List of new root nodes (eg. nodes with no parent)
  41062. */
  41063. rootNodes: TransformNode[];
  41064. /**
  41065. * List of new skeletons
  41066. */
  41067. skeletons: Skeleton[];
  41068. /**
  41069. * List of new animation groups
  41070. */
  41071. animationGroups: AnimationGroup[];
  41072. }
  41073. /**
  41074. * Container with a set of assets that can be added or removed from a scene.
  41075. */
  41076. export class AssetContainer extends AbstractScene {
  41077. private _wasAddedToScene;
  41078. /**
  41079. * The scene the AssetContainer belongs to.
  41080. */
  41081. scene: Scene;
  41082. /**
  41083. * Instantiates an AssetContainer.
  41084. * @param scene The scene the AssetContainer belongs to.
  41085. */
  41086. constructor(scene: Scene);
  41087. /**
  41088. * Instantiate or clone all meshes and add the new ones to the scene.
  41089. * Skeletons and animation groups will all be cloned
  41090. * @param nameFunction defines an optional function used to get new names for clones
  41091. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41092. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41093. */
  41094. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41095. /**
  41096. * Adds all the assets from the container to the scene.
  41097. */
  41098. addAllToScene(): void;
  41099. /**
  41100. * Removes all the assets in the container from the scene
  41101. */
  41102. removeAllFromScene(): void;
  41103. /**
  41104. * Disposes all the assets in the container
  41105. */
  41106. dispose(): void;
  41107. private _moveAssets;
  41108. /**
  41109. * Removes all the assets contained in the scene and adds them to the container.
  41110. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41111. */
  41112. moveAllFromScene(keepAssets?: KeepAssets): void;
  41113. /**
  41114. * 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.
  41115. * @returns the root mesh
  41116. */
  41117. createRootMesh(): Mesh;
  41118. /**
  41119. * Merge animations (direct and animation groups) from this asset container into a scene
  41120. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41121. * @param animatables set of animatables to retarget to a node from the scene
  41122. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41123. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41124. */
  41125. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41126. }
  41127. }
  41128. declare module BABYLON {
  41129. /**
  41130. * Defines how the parser contract is defined.
  41131. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41132. */
  41133. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41134. /**
  41135. * Defines how the individual parser contract is defined.
  41136. * These parser can parse an individual asset
  41137. */
  41138. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41139. /**
  41140. * Base class of the scene acting as a container for the different elements composing a scene.
  41141. * This class is dynamically extended by the different components of the scene increasing
  41142. * flexibility and reducing coupling
  41143. */
  41144. export abstract class AbstractScene {
  41145. /**
  41146. * Stores the list of available parsers in the application.
  41147. */
  41148. private static _BabylonFileParsers;
  41149. /**
  41150. * Stores the list of available individual parsers in the application.
  41151. */
  41152. private static _IndividualBabylonFileParsers;
  41153. /**
  41154. * Adds a parser in the list of available ones
  41155. * @param name Defines the name of the parser
  41156. * @param parser Defines the parser to add
  41157. */
  41158. static AddParser(name: string, parser: BabylonFileParser): void;
  41159. /**
  41160. * Gets a general parser from the list of avaialble ones
  41161. * @param name Defines the name of the parser
  41162. * @returns the requested parser or null
  41163. */
  41164. static GetParser(name: string): Nullable<BabylonFileParser>;
  41165. /**
  41166. * Adds n individual parser in the list of available ones
  41167. * @param name Defines the name of the parser
  41168. * @param parser Defines the parser to add
  41169. */
  41170. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41171. /**
  41172. * Gets an individual parser from the list of avaialble ones
  41173. * @param name Defines the name of the parser
  41174. * @returns the requested parser or null
  41175. */
  41176. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41177. /**
  41178. * Parser json data and populate both a scene and its associated container object
  41179. * @param jsonData Defines the data to parse
  41180. * @param scene Defines the scene to parse the data for
  41181. * @param container Defines the container attached to the parsing sequence
  41182. * @param rootUrl Defines the root url of the data
  41183. */
  41184. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41185. /**
  41186. * Gets the list of root nodes (ie. nodes with no parent)
  41187. */
  41188. rootNodes: Node[];
  41189. /** All of the cameras added to this scene
  41190. * @see https://doc.babylonjs.com/babylon101/cameras
  41191. */
  41192. cameras: Camera[];
  41193. /**
  41194. * All of the lights added to this scene
  41195. * @see https://doc.babylonjs.com/babylon101/lights
  41196. */
  41197. lights: Light[];
  41198. /**
  41199. * All of the (abstract) meshes added to this scene
  41200. */
  41201. meshes: AbstractMesh[];
  41202. /**
  41203. * The list of skeletons added to the scene
  41204. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41205. */
  41206. skeletons: Skeleton[];
  41207. /**
  41208. * All of the particle systems added to this scene
  41209. * @see https://doc.babylonjs.com/babylon101/particles
  41210. */
  41211. particleSystems: IParticleSystem[];
  41212. /**
  41213. * Gets a list of Animations associated with the scene
  41214. */
  41215. animations: Animation[];
  41216. /**
  41217. * All of the animation groups added to this scene
  41218. * @see https://doc.babylonjs.com/how_to/group
  41219. */
  41220. animationGroups: AnimationGroup[];
  41221. /**
  41222. * All of the multi-materials added to this scene
  41223. * @see https://doc.babylonjs.com/how_to/multi_materials
  41224. */
  41225. multiMaterials: MultiMaterial[];
  41226. /**
  41227. * All of the materials added to this scene
  41228. * In the context of a Scene, it is not supposed to be modified manually.
  41229. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41230. * Note also that the order of the Material within the array is not significant and might change.
  41231. * @see https://doc.babylonjs.com/babylon101/materials
  41232. */
  41233. materials: Material[];
  41234. /**
  41235. * The list of morph target managers added to the scene
  41236. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41237. */
  41238. morphTargetManagers: MorphTargetManager[];
  41239. /**
  41240. * The list of geometries used in the scene.
  41241. */
  41242. geometries: Geometry[];
  41243. /**
  41244. * All of the tranform nodes added to this scene
  41245. * In the context of a Scene, it is not supposed to be modified manually.
  41246. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41247. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41248. * @see https://doc.babylonjs.com/how_to/transformnode
  41249. */
  41250. transformNodes: TransformNode[];
  41251. /**
  41252. * ActionManagers available on the scene.
  41253. */
  41254. actionManagers: AbstractActionManager[];
  41255. /**
  41256. * Textures to keep.
  41257. */
  41258. textures: BaseTexture[];
  41259. /**
  41260. * Environment texture for the scene
  41261. */
  41262. environmentTexture: Nullable<BaseTexture>;
  41263. /**
  41264. * @returns all meshes, lights, cameras, transformNodes and bones
  41265. */
  41266. getNodes(): Array<Node>;
  41267. }
  41268. }
  41269. declare module BABYLON {
  41270. /**
  41271. * Interface used to define options for Sound class
  41272. */
  41273. export interface ISoundOptions {
  41274. /**
  41275. * Does the sound autoplay once loaded.
  41276. */
  41277. autoplay?: boolean;
  41278. /**
  41279. * Does the sound loop after it finishes playing once.
  41280. */
  41281. loop?: boolean;
  41282. /**
  41283. * Sound's volume
  41284. */
  41285. volume?: number;
  41286. /**
  41287. * Is it a spatial sound?
  41288. */
  41289. spatialSound?: boolean;
  41290. /**
  41291. * Maximum distance to hear that sound
  41292. */
  41293. maxDistance?: number;
  41294. /**
  41295. * Uses user defined attenuation function
  41296. */
  41297. useCustomAttenuation?: boolean;
  41298. /**
  41299. * Define the roll off factor of spatial sounds.
  41300. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41301. */
  41302. rolloffFactor?: number;
  41303. /**
  41304. * Define the reference distance the sound should be heard perfectly.
  41305. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41306. */
  41307. refDistance?: number;
  41308. /**
  41309. * Define the distance attenuation model the sound will follow.
  41310. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41311. */
  41312. distanceModel?: string;
  41313. /**
  41314. * Defines the playback speed (1 by default)
  41315. */
  41316. playbackRate?: number;
  41317. /**
  41318. * Defines if the sound is from a streaming source
  41319. */
  41320. streaming?: boolean;
  41321. /**
  41322. * Defines an optional length (in seconds) inside the sound file
  41323. */
  41324. length?: number;
  41325. /**
  41326. * Defines an optional offset (in seconds) inside the sound file
  41327. */
  41328. offset?: number;
  41329. /**
  41330. * If true, URLs will not be required to state the audio file codec to use.
  41331. */
  41332. skipCodecCheck?: boolean;
  41333. }
  41334. /**
  41335. * Defines a sound that can be played in the application.
  41336. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41337. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41338. */
  41339. export class Sound {
  41340. /**
  41341. * The name of the sound in the scene.
  41342. */
  41343. name: string;
  41344. /**
  41345. * Does the sound autoplay once loaded.
  41346. */
  41347. autoplay: boolean;
  41348. /**
  41349. * Does the sound loop after it finishes playing once.
  41350. */
  41351. loop: boolean;
  41352. /**
  41353. * Does the sound use a custom attenuation curve to simulate the falloff
  41354. * happening when the source gets further away from the camera.
  41355. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41356. */
  41357. useCustomAttenuation: boolean;
  41358. /**
  41359. * The sound track id this sound belongs to.
  41360. */
  41361. soundTrackId: number;
  41362. /**
  41363. * Is this sound currently played.
  41364. */
  41365. isPlaying: boolean;
  41366. /**
  41367. * Is this sound currently paused.
  41368. */
  41369. isPaused: boolean;
  41370. /**
  41371. * Does this sound enables spatial sound.
  41372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41373. */
  41374. spatialSound: boolean;
  41375. /**
  41376. * Define the reference distance the sound should be heard perfectly.
  41377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41378. */
  41379. refDistance: number;
  41380. /**
  41381. * Define the roll off factor of spatial sounds.
  41382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41383. */
  41384. rolloffFactor: number;
  41385. /**
  41386. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41387. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41388. */
  41389. maxDistance: number;
  41390. /**
  41391. * Define the distance attenuation model the sound will follow.
  41392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41393. */
  41394. distanceModel: string;
  41395. /**
  41396. * @hidden
  41397. * Back Compat
  41398. **/
  41399. onended: () => any;
  41400. /**
  41401. * Gets or sets an object used to store user defined information for the sound.
  41402. */
  41403. metadata: any;
  41404. /**
  41405. * Observable event when the current playing sound finishes.
  41406. */
  41407. onEndedObservable: Observable<Sound>;
  41408. private _panningModel;
  41409. private _playbackRate;
  41410. private _streaming;
  41411. private _startTime;
  41412. private _startOffset;
  41413. private _position;
  41414. /** @hidden */
  41415. _positionInEmitterSpace: boolean;
  41416. private _localDirection;
  41417. private _volume;
  41418. private _isReadyToPlay;
  41419. private _isDirectional;
  41420. private _readyToPlayCallback;
  41421. private _audioBuffer;
  41422. private _soundSource;
  41423. private _streamingSource;
  41424. private _soundPanner;
  41425. private _soundGain;
  41426. private _inputAudioNode;
  41427. private _outputAudioNode;
  41428. private _coneInnerAngle;
  41429. private _coneOuterAngle;
  41430. private _coneOuterGain;
  41431. private _scene;
  41432. private _connectedTransformNode;
  41433. private _customAttenuationFunction;
  41434. private _registerFunc;
  41435. private _isOutputConnected;
  41436. private _htmlAudioElement;
  41437. private _urlType;
  41438. private _length?;
  41439. private _offset?;
  41440. /** @hidden */
  41441. static _SceneComponentInitialization: (scene: Scene) => void;
  41442. /**
  41443. * Create a sound and attach it to a scene
  41444. * @param name Name of your sound
  41445. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41446. * @param scene defines the scene the sound belongs to
  41447. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41448. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41449. */
  41450. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41451. /**
  41452. * Release the sound and its associated resources
  41453. */
  41454. dispose(): void;
  41455. /**
  41456. * Gets if the sounds is ready to be played or not.
  41457. * @returns true if ready, otherwise false
  41458. */
  41459. isReady(): boolean;
  41460. private _soundLoaded;
  41461. /**
  41462. * Sets the data of the sound from an audiobuffer
  41463. * @param audioBuffer The audioBuffer containing the data
  41464. */
  41465. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41466. /**
  41467. * Updates the current sounds options such as maxdistance, loop...
  41468. * @param options A JSON object containing values named as the object properties
  41469. */
  41470. updateOptions(options: ISoundOptions): void;
  41471. private _createSpatialParameters;
  41472. private _updateSpatialParameters;
  41473. /**
  41474. * Switch the panning model to HRTF:
  41475. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41476. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41477. */
  41478. switchPanningModelToHRTF(): void;
  41479. /**
  41480. * Switch the panning model to Equal Power:
  41481. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41482. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41483. */
  41484. switchPanningModelToEqualPower(): void;
  41485. private _switchPanningModel;
  41486. /**
  41487. * Connect this sound to a sound track audio node like gain...
  41488. * @param soundTrackAudioNode the sound track audio node to connect to
  41489. */
  41490. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41491. /**
  41492. * Transform this sound into a directional source
  41493. * @param coneInnerAngle Size of the inner cone in degree
  41494. * @param coneOuterAngle Size of the outer cone in degree
  41495. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41496. */
  41497. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41498. /**
  41499. * Gets or sets the inner angle for the directional cone.
  41500. */
  41501. get directionalConeInnerAngle(): number;
  41502. /**
  41503. * Gets or sets the inner angle for the directional cone.
  41504. */
  41505. set directionalConeInnerAngle(value: number);
  41506. /**
  41507. * Gets or sets the outer angle for the directional cone.
  41508. */
  41509. get directionalConeOuterAngle(): number;
  41510. /**
  41511. * Gets or sets the outer angle for the directional cone.
  41512. */
  41513. set directionalConeOuterAngle(value: number);
  41514. /**
  41515. * Sets the position of the emitter if spatial sound is enabled
  41516. * @param newPosition Defines the new posisiton
  41517. */
  41518. setPosition(newPosition: Vector3): void;
  41519. /**
  41520. * Sets the local direction of the emitter if spatial sound is enabled
  41521. * @param newLocalDirection Defines the new local direction
  41522. */
  41523. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41524. private _updateDirection;
  41525. /** @hidden */
  41526. updateDistanceFromListener(): void;
  41527. /**
  41528. * Sets a new custom attenuation function for the sound.
  41529. * @param callback Defines the function used for the attenuation
  41530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41531. */
  41532. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41533. /**
  41534. * Play the sound
  41535. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41536. * @param offset (optional) Start the sound at a specific time in seconds
  41537. * @param length (optional) Sound duration (in seconds)
  41538. */
  41539. play(time?: number, offset?: number, length?: number): void;
  41540. private _onended;
  41541. /**
  41542. * Stop the sound
  41543. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41544. */
  41545. stop(time?: number): void;
  41546. /**
  41547. * Put the sound in pause
  41548. */
  41549. pause(): void;
  41550. /**
  41551. * Sets a dedicated volume for this sounds
  41552. * @param newVolume Define the new volume of the sound
  41553. * @param time Define time for gradual change to new volume
  41554. */
  41555. setVolume(newVolume: number, time?: number): void;
  41556. /**
  41557. * Set the sound play back rate
  41558. * @param newPlaybackRate Define the playback rate the sound should be played at
  41559. */
  41560. setPlaybackRate(newPlaybackRate: number): void;
  41561. /**
  41562. * Gets the volume of the sound.
  41563. * @returns the volume of the sound
  41564. */
  41565. getVolume(): number;
  41566. /**
  41567. * Attach the sound to a dedicated mesh
  41568. * @param transformNode The transform node to connect the sound with
  41569. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41570. */
  41571. attachToMesh(transformNode: TransformNode): void;
  41572. /**
  41573. * Detach the sound from the previously attached mesh
  41574. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41575. */
  41576. detachFromMesh(): void;
  41577. private _onRegisterAfterWorldMatrixUpdate;
  41578. /**
  41579. * Clone the current sound in the scene.
  41580. * @returns the new sound clone
  41581. */
  41582. clone(): Nullable<Sound>;
  41583. /**
  41584. * Gets the current underlying audio buffer containing the data
  41585. * @returns the audio buffer
  41586. */
  41587. getAudioBuffer(): Nullable<AudioBuffer>;
  41588. /**
  41589. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41590. * @returns the source node
  41591. */
  41592. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41593. /**
  41594. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41595. * @returns the gain node
  41596. */
  41597. getSoundGain(): Nullable<GainNode>;
  41598. /**
  41599. * Serializes the Sound in a JSON representation
  41600. * @returns the JSON representation of the sound
  41601. */
  41602. serialize(): any;
  41603. /**
  41604. * Parse a JSON representation of a sound to innstantiate in a given scene
  41605. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41606. * @param scene Define the scene the new parsed sound should be created in
  41607. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41608. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41609. * @returns the newly parsed sound
  41610. */
  41611. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41612. }
  41613. }
  41614. declare module BABYLON {
  41615. /**
  41616. * This defines an action helpful to play a defined sound on a triggered action.
  41617. */
  41618. export class PlaySoundAction extends Action {
  41619. private _sound;
  41620. /**
  41621. * Instantiate the action
  41622. * @param triggerOptions defines the trigger options
  41623. * @param sound defines the sound to play
  41624. * @param condition defines the trigger related conditions
  41625. */
  41626. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41627. /** @hidden */
  41628. _prepare(): void;
  41629. /**
  41630. * Execute the action and play the sound.
  41631. */
  41632. execute(): void;
  41633. /**
  41634. * Serializes the actions and its related information.
  41635. * @param parent defines the object to serialize in
  41636. * @returns the serialized object
  41637. */
  41638. serialize(parent: any): any;
  41639. }
  41640. /**
  41641. * This defines an action helpful to stop a defined sound on a triggered action.
  41642. */
  41643. export class StopSoundAction extends Action {
  41644. private _sound;
  41645. /**
  41646. * Instantiate the action
  41647. * @param triggerOptions defines the trigger options
  41648. * @param sound defines the sound to stop
  41649. * @param condition defines the trigger related conditions
  41650. */
  41651. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41652. /** @hidden */
  41653. _prepare(): void;
  41654. /**
  41655. * Execute the action and stop the sound.
  41656. */
  41657. execute(): void;
  41658. /**
  41659. * Serializes the actions and its related information.
  41660. * @param parent defines the object to serialize in
  41661. * @returns the serialized object
  41662. */
  41663. serialize(parent: any): any;
  41664. }
  41665. }
  41666. declare module BABYLON {
  41667. /**
  41668. * This defines an action responsible to change the value of a property
  41669. * by interpolating between its current value and the newly set one once triggered.
  41670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41671. */
  41672. export class InterpolateValueAction extends Action {
  41673. /**
  41674. * Defines the path of the property where the value should be interpolated
  41675. */
  41676. propertyPath: string;
  41677. /**
  41678. * Defines the target value at the end of the interpolation.
  41679. */
  41680. value: any;
  41681. /**
  41682. * Defines the time it will take for the property to interpolate to the value.
  41683. */
  41684. duration: number;
  41685. /**
  41686. * Defines if the other scene animations should be stopped when the action has been triggered
  41687. */
  41688. stopOtherAnimations?: boolean;
  41689. /**
  41690. * Defines a callback raised once the interpolation animation has been done.
  41691. */
  41692. onInterpolationDone?: () => void;
  41693. /**
  41694. * Observable triggered once the interpolation animation has been done.
  41695. */
  41696. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41697. private _target;
  41698. private _effectiveTarget;
  41699. private _property;
  41700. /**
  41701. * Instantiate the action
  41702. * @param triggerOptions defines the trigger options
  41703. * @param target defines the object containing the value to interpolate
  41704. * @param propertyPath defines the path to the property in the target object
  41705. * @param value defines the target value at the end of the interpolation
  41706. * @param duration deines the time it will take for the property to interpolate to the value.
  41707. * @param condition defines the trigger related conditions
  41708. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41709. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41710. */
  41711. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41712. /** @hidden */
  41713. _prepare(): void;
  41714. /**
  41715. * Execute the action starts the value interpolation.
  41716. */
  41717. execute(): void;
  41718. /**
  41719. * Serializes the actions and its related information.
  41720. * @param parent defines the object to serialize in
  41721. * @returns the serialized object
  41722. */
  41723. serialize(parent: any): any;
  41724. }
  41725. }
  41726. declare module BABYLON {
  41727. /**
  41728. * Options allowed during the creation of a sound track.
  41729. */
  41730. export interface ISoundTrackOptions {
  41731. /**
  41732. * The volume the sound track should take during creation
  41733. */
  41734. volume?: number;
  41735. /**
  41736. * Define if the sound track is the main sound track of the scene
  41737. */
  41738. mainTrack?: boolean;
  41739. }
  41740. /**
  41741. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41742. * It will be also used in a future release to apply effects on a specific track.
  41743. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41744. */
  41745. export class SoundTrack {
  41746. /**
  41747. * The unique identifier of the sound track in the scene.
  41748. */
  41749. id: number;
  41750. /**
  41751. * The list of sounds included in the sound track.
  41752. */
  41753. soundCollection: Array<Sound>;
  41754. private _outputAudioNode;
  41755. private _scene;
  41756. private _connectedAnalyser;
  41757. private _options;
  41758. private _isInitialized;
  41759. /**
  41760. * Creates a new sound track.
  41761. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41762. * @param scene Define the scene the sound track belongs to
  41763. * @param options
  41764. */
  41765. constructor(scene: Scene, options?: ISoundTrackOptions);
  41766. private _initializeSoundTrackAudioGraph;
  41767. /**
  41768. * Release the sound track and its associated resources
  41769. */
  41770. dispose(): void;
  41771. /**
  41772. * Adds a sound to this sound track
  41773. * @param sound define the cound to add
  41774. * @ignoreNaming
  41775. */
  41776. AddSound(sound: Sound): void;
  41777. /**
  41778. * Removes a sound to this sound track
  41779. * @param sound define the cound to remove
  41780. * @ignoreNaming
  41781. */
  41782. RemoveSound(sound: Sound): void;
  41783. /**
  41784. * Set a global volume for the full sound track.
  41785. * @param newVolume Define the new volume of the sound track
  41786. */
  41787. setVolume(newVolume: number): void;
  41788. /**
  41789. * Switch the panning model to HRTF:
  41790. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41791. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41792. */
  41793. switchPanningModelToHRTF(): void;
  41794. /**
  41795. * Switch the panning model to Equal Power:
  41796. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41798. */
  41799. switchPanningModelToEqualPower(): void;
  41800. /**
  41801. * Connect the sound track to an audio analyser allowing some amazing
  41802. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41804. * @param analyser The analyser to connect to the engine
  41805. */
  41806. connectToAnalyser(analyser: Analyser): void;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. interface AbstractScene {
  41811. /**
  41812. * The list of sounds used in the scene.
  41813. */
  41814. sounds: Nullable<Array<Sound>>;
  41815. }
  41816. interface Scene {
  41817. /**
  41818. * @hidden
  41819. * Backing field
  41820. */
  41821. _mainSoundTrack: SoundTrack;
  41822. /**
  41823. * The main sound track played by the scene.
  41824. * It cotains your primary collection of sounds.
  41825. */
  41826. mainSoundTrack: SoundTrack;
  41827. /**
  41828. * The list of sound tracks added to the scene
  41829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41830. */
  41831. soundTracks: Nullable<Array<SoundTrack>>;
  41832. /**
  41833. * Gets a sound using a given name
  41834. * @param name defines the name to search for
  41835. * @return the found sound or null if not found at all.
  41836. */
  41837. getSoundByName(name: string): Nullable<Sound>;
  41838. /**
  41839. * Gets or sets if audio support is enabled
  41840. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41841. */
  41842. audioEnabled: boolean;
  41843. /**
  41844. * Gets or sets if audio will be output to headphones
  41845. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41846. */
  41847. headphone: boolean;
  41848. /**
  41849. * Gets or sets custom audio listener position provider
  41850. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41851. */
  41852. audioListenerPositionProvider: Nullable<() => Vector3>;
  41853. /**
  41854. * Gets or sets a refresh rate when using 3D audio positioning
  41855. */
  41856. audioPositioningRefreshRate: number;
  41857. }
  41858. /**
  41859. * Defines the sound scene component responsible to manage any sounds
  41860. * in a given scene.
  41861. */
  41862. export class AudioSceneComponent implements ISceneSerializableComponent {
  41863. /**
  41864. * The component name helpfull to identify the component in the list of scene components.
  41865. */
  41866. readonly name: string;
  41867. /**
  41868. * The scene the component belongs to.
  41869. */
  41870. scene: Scene;
  41871. private _audioEnabled;
  41872. /**
  41873. * Gets whether audio is enabled or not.
  41874. * Please use related enable/disable method to switch state.
  41875. */
  41876. get audioEnabled(): boolean;
  41877. private _headphone;
  41878. /**
  41879. * Gets whether audio is outputing to headphone or not.
  41880. * Please use the according Switch methods to change output.
  41881. */
  41882. get headphone(): boolean;
  41883. /**
  41884. * Gets or sets a refresh rate when using 3D audio positioning
  41885. */
  41886. audioPositioningRefreshRate: number;
  41887. private _audioListenerPositionProvider;
  41888. /**
  41889. * Gets the current audio listener position provider
  41890. */
  41891. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41892. /**
  41893. * Sets a custom listener position for all sounds in the scene
  41894. * By default, this is the position of the first active camera
  41895. */
  41896. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41897. /**
  41898. * Creates a new instance of the component for the given scene
  41899. * @param scene Defines the scene to register the component in
  41900. */
  41901. constructor(scene: Scene);
  41902. /**
  41903. * Registers the component in a given scene
  41904. */
  41905. register(): void;
  41906. /**
  41907. * Rebuilds the elements related to this component in case of
  41908. * context lost for instance.
  41909. */
  41910. rebuild(): void;
  41911. /**
  41912. * Serializes the component data to the specified json object
  41913. * @param serializationObject The object to serialize to
  41914. */
  41915. serialize(serializationObject: any): void;
  41916. /**
  41917. * Adds all the elements from the container to the scene
  41918. * @param container the container holding the elements
  41919. */
  41920. addFromContainer(container: AbstractScene): void;
  41921. /**
  41922. * Removes all the elements in the container from the scene
  41923. * @param container contains the elements to remove
  41924. * @param dispose if the removed element should be disposed (default: false)
  41925. */
  41926. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41927. /**
  41928. * Disposes the component and the associated ressources.
  41929. */
  41930. dispose(): void;
  41931. /**
  41932. * Disables audio in the associated scene.
  41933. */
  41934. disableAudio(): void;
  41935. /**
  41936. * Enables audio in the associated scene.
  41937. */
  41938. enableAudio(): void;
  41939. /**
  41940. * Switch audio to headphone output.
  41941. */
  41942. switchAudioModeForHeadphones(): void;
  41943. /**
  41944. * Switch audio to normal speakers.
  41945. */
  41946. switchAudioModeForNormalSpeakers(): void;
  41947. private _cachedCameraDirection;
  41948. private _cachedCameraPosition;
  41949. private _lastCheck;
  41950. private _afterRender;
  41951. }
  41952. }
  41953. declare module BABYLON {
  41954. /**
  41955. * Wraps one or more Sound objects and selects one with random weight for playback.
  41956. */
  41957. export class WeightedSound {
  41958. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41959. loop: boolean;
  41960. private _coneInnerAngle;
  41961. private _coneOuterAngle;
  41962. private _volume;
  41963. /** A Sound is currently playing. */
  41964. isPlaying: boolean;
  41965. /** A Sound is currently paused. */
  41966. isPaused: boolean;
  41967. private _sounds;
  41968. private _weights;
  41969. private _currentIndex?;
  41970. /**
  41971. * Creates a new WeightedSound from the list of sounds given.
  41972. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41973. * @param sounds Array of Sounds that will be selected from.
  41974. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41975. */
  41976. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41977. /**
  41978. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41979. */
  41980. get directionalConeInnerAngle(): number;
  41981. /**
  41982. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41983. */
  41984. set directionalConeInnerAngle(value: number);
  41985. /**
  41986. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41987. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41988. */
  41989. get directionalConeOuterAngle(): number;
  41990. /**
  41991. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41992. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41993. */
  41994. set directionalConeOuterAngle(value: number);
  41995. /**
  41996. * Playback volume.
  41997. */
  41998. get volume(): number;
  41999. /**
  42000. * Playback volume.
  42001. */
  42002. set volume(value: number);
  42003. private _onended;
  42004. /**
  42005. * Suspend playback
  42006. */
  42007. pause(): void;
  42008. /**
  42009. * Stop playback
  42010. */
  42011. stop(): void;
  42012. /**
  42013. * Start playback.
  42014. * @param startOffset Position the clip head at a specific time in seconds.
  42015. */
  42016. play(startOffset?: number): void;
  42017. }
  42018. }
  42019. declare module BABYLON {
  42020. /**
  42021. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42022. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42023. */
  42024. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42025. /**
  42026. * Gets the name of the behavior.
  42027. */
  42028. get name(): string;
  42029. /**
  42030. * The easing function used by animations
  42031. */
  42032. static EasingFunction: BackEase;
  42033. /**
  42034. * The easing mode used by animations
  42035. */
  42036. static EasingMode: number;
  42037. /**
  42038. * The duration of the animation, in milliseconds
  42039. */
  42040. transitionDuration: number;
  42041. /**
  42042. * Length of the distance animated by the transition when lower radius is reached
  42043. */
  42044. lowerRadiusTransitionRange: number;
  42045. /**
  42046. * Length of the distance animated by the transition when upper radius is reached
  42047. */
  42048. upperRadiusTransitionRange: number;
  42049. private _autoTransitionRange;
  42050. /**
  42051. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42052. */
  42053. get autoTransitionRange(): boolean;
  42054. /**
  42055. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42056. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42057. */
  42058. set autoTransitionRange(value: boolean);
  42059. private _attachedCamera;
  42060. private _onAfterCheckInputsObserver;
  42061. private _onMeshTargetChangedObserver;
  42062. /**
  42063. * Initializes the behavior.
  42064. */
  42065. init(): void;
  42066. /**
  42067. * Attaches the behavior to its arc rotate camera.
  42068. * @param camera Defines the camera to attach the behavior to
  42069. */
  42070. attach(camera: ArcRotateCamera): void;
  42071. /**
  42072. * Detaches the behavior from its current arc rotate camera.
  42073. */
  42074. detach(): void;
  42075. private _radiusIsAnimating;
  42076. private _radiusBounceTransition;
  42077. private _animatables;
  42078. private _cachedWheelPrecision;
  42079. /**
  42080. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42081. * @param radiusLimit The limit to check against.
  42082. * @return Bool to indicate if at limit.
  42083. */
  42084. private _isRadiusAtLimit;
  42085. /**
  42086. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42087. * @param radiusDelta The delta by which to animate to. Can be negative.
  42088. */
  42089. private _applyBoundRadiusAnimation;
  42090. /**
  42091. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42092. */
  42093. protected _clearAnimationLocks(): void;
  42094. /**
  42095. * Stops and removes all animations that have been applied to the camera
  42096. */
  42097. stopAllAnimations(): void;
  42098. }
  42099. }
  42100. declare module BABYLON {
  42101. /**
  42102. * 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.
  42103. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42104. */
  42105. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42106. /**
  42107. * Gets the name of the behavior.
  42108. */
  42109. get name(): string;
  42110. private _mode;
  42111. private _radiusScale;
  42112. private _positionScale;
  42113. private _defaultElevation;
  42114. private _elevationReturnTime;
  42115. private _elevationReturnWaitTime;
  42116. private _zoomStopsAnimation;
  42117. private _framingTime;
  42118. /**
  42119. * The easing function used by animations
  42120. */
  42121. static EasingFunction: ExponentialEase;
  42122. /**
  42123. * The easing mode used by animations
  42124. */
  42125. static EasingMode: number;
  42126. /**
  42127. * Sets the current mode used by the behavior
  42128. */
  42129. set mode(mode: number);
  42130. /**
  42131. * Gets current mode used by the behavior.
  42132. */
  42133. get mode(): number;
  42134. /**
  42135. * Sets the scale applied to the radius (1 by default)
  42136. */
  42137. set radiusScale(radius: number);
  42138. /**
  42139. * Gets the scale applied to the radius
  42140. */
  42141. get radiusScale(): number;
  42142. /**
  42143. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42144. */
  42145. set positionScale(scale: number);
  42146. /**
  42147. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42148. */
  42149. get positionScale(): number;
  42150. /**
  42151. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42152. * behaviour is triggered, in radians.
  42153. */
  42154. set defaultElevation(elevation: number);
  42155. /**
  42156. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42157. * behaviour is triggered, in radians.
  42158. */
  42159. get defaultElevation(): number;
  42160. /**
  42161. * Sets the time (in milliseconds) taken to return to the default beta position.
  42162. * Negative value indicates camera should not return to default.
  42163. */
  42164. set elevationReturnTime(speed: number);
  42165. /**
  42166. * Gets the time (in milliseconds) taken to return to the default beta position.
  42167. * Negative value indicates camera should not return to default.
  42168. */
  42169. get elevationReturnTime(): number;
  42170. /**
  42171. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42172. */
  42173. set elevationReturnWaitTime(time: number);
  42174. /**
  42175. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42176. */
  42177. get elevationReturnWaitTime(): number;
  42178. /**
  42179. * Sets the flag that indicates if user zooming should stop animation.
  42180. */
  42181. set zoomStopsAnimation(flag: boolean);
  42182. /**
  42183. * Gets the flag that indicates if user zooming should stop animation.
  42184. */
  42185. get zoomStopsAnimation(): boolean;
  42186. /**
  42187. * Sets the transition time when framing the mesh, in milliseconds
  42188. */
  42189. set framingTime(time: number);
  42190. /**
  42191. * Gets the transition time when framing the mesh, in milliseconds
  42192. */
  42193. get framingTime(): number;
  42194. /**
  42195. * Define if the behavior should automatically change the configured
  42196. * camera limits and sensibilities.
  42197. */
  42198. autoCorrectCameraLimitsAndSensibility: boolean;
  42199. private _onPrePointerObservableObserver;
  42200. private _onAfterCheckInputsObserver;
  42201. private _onMeshTargetChangedObserver;
  42202. private _attachedCamera;
  42203. private _isPointerDown;
  42204. private _lastInteractionTime;
  42205. /**
  42206. * Initializes the behavior.
  42207. */
  42208. init(): void;
  42209. /**
  42210. * Attaches the behavior to its arc rotate camera.
  42211. * @param camera Defines the camera to attach the behavior to
  42212. */
  42213. attach(camera: ArcRotateCamera): void;
  42214. /**
  42215. * Detaches the behavior from its current arc rotate camera.
  42216. */
  42217. detach(): void;
  42218. private _animatables;
  42219. private _betaIsAnimating;
  42220. private _betaTransition;
  42221. private _radiusTransition;
  42222. private _vectorTransition;
  42223. /**
  42224. * Targets the given mesh and updates zoom level accordingly.
  42225. * @param mesh The mesh to target.
  42226. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42227. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42228. */
  42229. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42230. /**
  42231. * Targets the given mesh with its children and updates zoom level accordingly.
  42232. * @param mesh The mesh to target.
  42233. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42234. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42235. */
  42236. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42237. /**
  42238. * Targets the given meshes with their children and updates zoom level accordingly.
  42239. * @param meshes The mesh to target.
  42240. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42241. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42242. */
  42243. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42244. /**
  42245. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42246. * @param minimumWorld Determines the smaller position of the bounding box extend
  42247. * @param maximumWorld Determines the bigger position of the bounding box extend
  42248. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42249. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42250. */
  42251. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42252. /**
  42253. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42254. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42255. * frustum width.
  42256. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42257. * to fully enclose the mesh in the viewing frustum.
  42258. */
  42259. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42260. /**
  42261. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42262. * is automatically returned to its default position (expected to be above ground plane).
  42263. */
  42264. private _maintainCameraAboveGround;
  42265. /**
  42266. * Returns the frustum slope based on the canvas ratio and camera FOV
  42267. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42268. */
  42269. private _getFrustumSlope;
  42270. /**
  42271. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42272. */
  42273. private _clearAnimationLocks;
  42274. /**
  42275. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42276. */
  42277. private _applyUserInteraction;
  42278. /**
  42279. * Stops and removes all animations that have been applied to the camera
  42280. */
  42281. stopAllAnimations(): void;
  42282. /**
  42283. * Gets a value indicating if the user is moving the camera
  42284. */
  42285. get isUserIsMoving(): boolean;
  42286. /**
  42287. * The camera can move all the way towards the mesh.
  42288. */
  42289. static IgnoreBoundsSizeMode: number;
  42290. /**
  42291. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42292. */
  42293. static FitFrustumSidesMode: number;
  42294. }
  42295. }
  42296. declare module BABYLON {
  42297. /**
  42298. * Base class for Camera Pointer Inputs.
  42299. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42300. * for example usage.
  42301. */
  42302. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42303. /**
  42304. * Defines the camera the input is attached to.
  42305. */
  42306. abstract camera: Camera;
  42307. /**
  42308. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42309. */
  42310. protected _altKey: boolean;
  42311. protected _ctrlKey: boolean;
  42312. protected _metaKey: boolean;
  42313. protected _shiftKey: boolean;
  42314. /**
  42315. * Which mouse buttons were pressed at time of last mouse event.
  42316. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42317. */
  42318. protected _buttonsPressed: number;
  42319. /**
  42320. * Defines the buttons associated with the input to handle camera move.
  42321. */
  42322. buttons: number[];
  42323. /**
  42324. * Attach the input controls to a specific dom element to get the input from.
  42325. * @param element Defines the element the controls should be listened from
  42326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42327. */
  42328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42329. /**
  42330. * Detach the current controls from the specified dom element.
  42331. * @param element Defines the element to stop listening the inputs from
  42332. */
  42333. detachControl(element: Nullable<HTMLElement>): void;
  42334. /**
  42335. * Gets the class name of the current input.
  42336. * @returns the class name
  42337. */
  42338. getClassName(): string;
  42339. /**
  42340. * Get the friendly name associated with the input class.
  42341. * @returns the input friendly name
  42342. */
  42343. getSimpleName(): string;
  42344. /**
  42345. * Called on pointer POINTERDOUBLETAP event.
  42346. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42347. */
  42348. protected onDoubleTap(type: string): void;
  42349. /**
  42350. * Called on pointer POINTERMOVE event if only a single touch is active.
  42351. * Override this method to provide functionality.
  42352. */
  42353. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42354. /**
  42355. * Called on pointer POINTERMOVE event if multiple touches are active.
  42356. * Override this method to provide functionality.
  42357. */
  42358. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42359. /**
  42360. * Called on JS contextmenu event.
  42361. * Override this method to provide functionality.
  42362. */
  42363. protected onContextMenu(evt: PointerEvent): void;
  42364. /**
  42365. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42366. * press.
  42367. * Override this method to provide functionality.
  42368. */
  42369. protected onButtonDown(evt: PointerEvent): void;
  42370. /**
  42371. * Called each time a new POINTERUP event occurs. Ie, for each button
  42372. * release.
  42373. * Override this method to provide functionality.
  42374. */
  42375. protected onButtonUp(evt: PointerEvent): void;
  42376. /**
  42377. * Called when window becomes inactive.
  42378. * Override this method to provide functionality.
  42379. */
  42380. protected onLostFocus(): void;
  42381. private _pointerInput;
  42382. private _observer;
  42383. private _onLostFocus;
  42384. private pointA;
  42385. private pointB;
  42386. }
  42387. }
  42388. declare module BABYLON {
  42389. /**
  42390. * Manage the pointers inputs to control an arc rotate camera.
  42391. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42392. */
  42393. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42394. /**
  42395. * Defines the camera the input is attached to.
  42396. */
  42397. camera: ArcRotateCamera;
  42398. /**
  42399. * Gets the class name of the current input.
  42400. * @returns the class name
  42401. */
  42402. getClassName(): string;
  42403. /**
  42404. * Defines the buttons associated with the input to handle camera move.
  42405. */
  42406. buttons: number[];
  42407. /**
  42408. * Defines the pointer angular sensibility along the X axis or how fast is
  42409. * the camera rotating.
  42410. */
  42411. angularSensibilityX: number;
  42412. /**
  42413. * Defines the pointer angular sensibility along the Y axis or how fast is
  42414. * the camera rotating.
  42415. */
  42416. angularSensibilityY: number;
  42417. /**
  42418. * Defines the pointer pinch precision or how fast is the camera zooming.
  42419. */
  42420. pinchPrecision: number;
  42421. /**
  42422. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42423. * from 0.
  42424. * It defines the percentage of current camera.radius to use as delta when
  42425. * pinch zoom is used.
  42426. */
  42427. pinchDeltaPercentage: number;
  42428. /**
  42429. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42430. * that any object in the plane at the camera's target point will scale
  42431. * perfectly with finger motion.
  42432. * Overrides pinchDeltaPercentage and pinchPrecision.
  42433. */
  42434. useNaturalPinchZoom: boolean;
  42435. /**
  42436. * Defines the pointer panning sensibility or how fast is the camera moving.
  42437. */
  42438. panningSensibility: number;
  42439. /**
  42440. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42441. */
  42442. multiTouchPanning: boolean;
  42443. /**
  42444. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42445. * zoom (pinch) through multitouch.
  42446. */
  42447. multiTouchPanAndZoom: boolean;
  42448. /**
  42449. * Revers pinch action direction.
  42450. */
  42451. pinchInwards: boolean;
  42452. private _isPanClick;
  42453. private _twoFingerActivityCount;
  42454. private _isPinching;
  42455. /**
  42456. * Called on pointer POINTERMOVE event if only a single touch is active.
  42457. */
  42458. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42459. /**
  42460. * Called on pointer POINTERDOUBLETAP event.
  42461. */
  42462. protected onDoubleTap(type: string): void;
  42463. /**
  42464. * Called on pointer POINTERMOVE event if multiple touches are active.
  42465. */
  42466. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42467. /**
  42468. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42469. * press.
  42470. */
  42471. protected onButtonDown(evt: PointerEvent): void;
  42472. /**
  42473. * Called each time a new POINTERUP event occurs. Ie, for each button
  42474. * release.
  42475. */
  42476. protected onButtonUp(evt: PointerEvent): void;
  42477. /**
  42478. * Called when window becomes inactive.
  42479. */
  42480. protected onLostFocus(): void;
  42481. }
  42482. }
  42483. declare module BABYLON {
  42484. /**
  42485. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42486. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42487. */
  42488. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42489. /**
  42490. * Defines the camera the input is attached to.
  42491. */
  42492. camera: ArcRotateCamera;
  42493. /**
  42494. * Defines the list of key codes associated with the up action (increase alpha)
  42495. */
  42496. keysUp: number[];
  42497. /**
  42498. * Defines the list of key codes associated with the down action (decrease alpha)
  42499. */
  42500. keysDown: number[];
  42501. /**
  42502. * Defines the list of key codes associated with the left action (increase beta)
  42503. */
  42504. keysLeft: number[];
  42505. /**
  42506. * Defines the list of key codes associated with the right action (decrease beta)
  42507. */
  42508. keysRight: number[];
  42509. /**
  42510. * Defines the list of key codes associated with the reset action.
  42511. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42512. */
  42513. keysReset: number[];
  42514. /**
  42515. * Defines the panning sensibility of the inputs.
  42516. * (How fast is the camera panning)
  42517. */
  42518. panningSensibility: number;
  42519. /**
  42520. * Defines the zooming sensibility of the inputs.
  42521. * (How fast is the camera zooming)
  42522. */
  42523. zoomingSensibility: number;
  42524. /**
  42525. * Defines whether maintaining the alt key down switch the movement mode from
  42526. * orientation to zoom.
  42527. */
  42528. useAltToZoom: boolean;
  42529. /**
  42530. * Rotation speed of the camera
  42531. */
  42532. angularSpeed: number;
  42533. private _keys;
  42534. private _ctrlPressed;
  42535. private _altPressed;
  42536. private _onCanvasBlurObserver;
  42537. private _onKeyboardObserver;
  42538. private _engine;
  42539. private _scene;
  42540. /**
  42541. * Attach the input controls to a specific dom element to get the input from.
  42542. * @param element Defines the element the controls should be listened from
  42543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42544. */
  42545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42546. /**
  42547. * Detach the current controls from the specified dom element.
  42548. * @param element Defines the element to stop listening the inputs from
  42549. */
  42550. detachControl(element: Nullable<HTMLElement>): void;
  42551. /**
  42552. * Update the current camera state depending on the inputs that have been used this frame.
  42553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42554. */
  42555. checkInputs(): void;
  42556. /**
  42557. * Gets the class name of the current intput.
  42558. * @returns the class name
  42559. */
  42560. getClassName(): string;
  42561. /**
  42562. * Get the friendly name associated with the input class.
  42563. * @returns the input friendly name
  42564. */
  42565. getSimpleName(): string;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Manage the mouse wheel inputs to control an arc rotate camera.
  42571. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42572. */
  42573. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42574. /**
  42575. * Defines the camera the input is attached to.
  42576. */
  42577. camera: ArcRotateCamera;
  42578. /**
  42579. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42580. */
  42581. wheelPrecision: number;
  42582. /**
  42583. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42584. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42585. */
  42586. wheelDeltaPercentage: number;
  42587. private _wheel;
  42588. private _observer;
  42589. private computeDeltaFromMouseWheelLegacyEvent;
  42590. /**
  42591. * Attach the input controls to a specific dom element to get the input from.
  42592. * @param element Defines the element the controls should be listened from
  42593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42594. */
  42595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42596. /**
  42597. * Detach the current controls from the specified dom element.
  42598. * @param element Defines the element to stop listening the inputs from
  42599. */
  42600. detachControl(element: Nullable<HTMLElement>): void;
  42601. /**
  42602. * Gets the class name of the current intput.
  42603. * @returns the class name
  42604. */
  42605. getClassName(): string;
  42606. /**
  42607. * Get the friendly name associated with the input class.
  42608. * @returns the input friendly name
  42609. */
  42610. getSimpleName(): string;
  42611. }
  42612. }
  42613. declare module BABYLON {
  42614. /**
  42615. * Default Inputs manager for the ArcRotateCamera.
  42616. * It groups all the default supported inputs for ease of use.
  42617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42618. */
  42619. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42620. /**
  42621. * Instantiates a new ArcRotateCameraInputsManager.
  42622. * @param camera Defines the camera the inputs belong to
  42623. */
  42624. constructor(camera: ArcRotateCamera);
  42625. /**
  42626. * Add mouse wheel input support to the input manager.
  42627. * @returns the current input manager
  42628. */
  42629. addMouseWheel(): ArcRotateCameraInputsManager;
  42630. /**
  42631. * Add pointers input support to the input manager.
  42632. * @returns the current input manager
  42633. */
  42634. addPointers(): ArcRotateCameraInputsManager;
  42635. /**
  42636. * Add keyboard input support to the input manager.
  42637. * @returns the current input manager
  42638. */
  42639. addKeyboard(): ArcRotateCameraInputsManager;
  42640. }
  42641. }
  42642. declare module BABYLON {
  42643. /**
  42644. * This represents an orbital type of camera.
  42645. *
  42646. * 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.
  42647. * 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.
  42648. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42649. */
  42650. export class ArcRotateCamera extends TargetCamera {
  42651. /**
  42652. * Defines the rotation angle of the camera along the longitudinal axis.
  42653. */
  42654. alpha: number;
  42655. /**
  42656. * Defines the rotation angle of the camera along the latitudinal axis.
  42657. */
  42658. beta: number;
  42659. /**
  42660. * Defines the radius of the camera from it s target point.
  42661. */
  42662. radius: number;
  42663. protected _target: Vector3;
  42664. protected _targetHost: Nullable<AbstractMesh>;
  42665. /**
  42666. * Defines the target point of the camera.
  42667. * The camera looks towards it form the radius distance.
  42668. */
  42669. get target(): Vector3;
  42670. set target(value: Vector3);
  42671. /**
  42672. * Define the current local position of the camera in the scene
  42673. */
  42674. get position(): Vector3;
  42675. set position(newPosition: Vector3);
  42676. protected _upVector: Vector3;
  42677. protected _upToYMatrix: Matrix;
  42678. protected _YToUpMatrix: Matrix;
  42679. /**
  42680. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42681. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42682. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42683. */
  42684. set upVector(vec: Vector3);
  42685. get upVector(): Vector3;
  42686. /**
  42687. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42688. */
  42689. setMatUp(): void;
  42690. /**
  42691. * Current inertia value on the longitudinal axis.
  42692. * The bigger this number the longer it will take for the camera to stop.
  42693. */
  42694. inertialAlphaOffset: number;
  42695. /**
  42696. * Current inertia value on the latitudinal axis.
  42697. * The bigger this number the longer it will take for the camera to stop.
  42698. */
  42699. inertialBetaOffset: number;
  42700. /**
  42701. * Current inertia value on the radius axis.
  42702. * The bigger this number the longer it will take for the camera to stop.
  42703. */
  42704. inertialRadiusOffset: number;
  42705. /**
  42706. * Minimum allowed angle on the longitudinal axis.
  42707. * This can help limiting how the Camera is able to move in the scene.
  42708. */
  42709. lowerAlphaLimit: Nullable<number>;
  42710. /**
  42711. * Maximum allowed angle on the longitudinal axis.
  42712. * This can help limiting how the Camera is able to move in the scene.
  42713. */
  42714. upperAlphaLimit: Nullable<number>;
  42715. /**
  42716. * Minimum allowed angle on the latitudinal axis.
  42717. * This can help limiting how the Camera is able to move in the scene.
  42718. */
  42719. lowerBetaLimit: number;
  42720. /**
  42721. * Maximum allowed angle on the latitudinal axis.
  42722. * This can help limiting how the Camera is able to move in the scene.
  42723. */
  42724. upperBetaLimit: number;
  42725. /**
  42726. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42727. * This can help limiting how the Camera is able to move in the scene.
  42728. */
  42729. lowerRadiusLimit: Nullable<number>;
  42730. /**
  42731. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42732. * This can help limiting how the Camera is able to move in the scene.
  42733. */
  42734. upperRadiusLimit: Nullable<number>;
  42735. /**
  42736. * Defines the current inertia value used during panning of the camera along the X axis.
  42737. */
  42738. inertialPanningX: number;
  42739. /**
  42740. * Defines the current inertia value used during panning of the camera along the Y axis.
  42741. */
  42742. inertialPanningY: number;
  42743. /**
  42744. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42745. * Basically if your fingers moves away from more than this distance you will be considered
  42746. * in pinch mode.
  42747. */
  42748. pinchToPanMaxDistance: number;
  42749. /**
  42750. * Defines the maximum distance the camera can pan.
  42751. * This could help keeping the cammera always in your scene.
  42752. */
  42753. panningDistanceLimit: Nullable<number>;
  42754. /**
  42755. * Defines the target of the camera before paning.
  42756. */
  42757. panningOriginTarget: Vector3;
  42758. /**
  42759. * Defines the value of the inertia used during panning.
  42760. * 0 would mean stop inertia and one would mean no decelleration at all.
  42761. */
  42762. panningInertia: number;
  42763. /**
  42764. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42765. */
  42766. get angularSensibilityX(): number;
  42767. set angularSensibilityX(value: number);
  42768. /**
  42769. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42770. */
  42771. get angularSensibilityY(): number;
  42772. set angularSensibilityY(value: number);
  42773. /**
  42774. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42775. */
  42776. get pinchPrecision(): number;
  42777. set pinchPrecision(value: number);
  42778. /**
  42779. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42780. * It will be used instead of pinchDeltaPrecision if different from 0.
  42781. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42782. */
  42783. get pinchDeltaPercentage(): number;
  42784. set pinchDeltaPercentage(value: number);
  42785. /**
  42786. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42787. * and pinch delta percentage.
  42788. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42789. * that any object in the plane at the camera's target point will scale
  42790. * perfectly with finger motion.
  42791. */
  42792. get useNaturalPinchZoom(): boolean;
  42793. set useNaturalPinchZoom(value: boolean);
  42794. /**
  42795. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42796. */
  42797. get panningSensibility(): number;
  42798. set panningSensibility(value: number);
  42799. /**
  42800. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42801. */
  42802. get keysUp(): number[];
  42803. set keysUp(value: number[]);
  42804. /**
  42805. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42806. */
  42807. get keysDown(): number[];
  42808. set keysDown(value: number[]);
  42809. /**
  42810. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42811. */
  42812. get keysLeft(): number[];
  42813. set keysLeft(value: number[]);
  42814. /**
  42815. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42816. */
  42817. get keysRight(): number[];
  42818. set keysRight(value: number[]);
  42819. /**
  42820. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42821. */
  42822. get wheelPrecision(): number;
  42823. set wheelPrecision(value: number);
  42824. /**
  42825. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42826. * It will be used instead of pinchDeltaPrecision if different from 0.
  42827. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42828. */
  42829. get wheelDeltaPercentage(): number;
  42830. set wheelDeltaPercentage(value: number);
  42831. /**
  42832. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42833. */
  42834. zoomOnFactor: number;
  42835. /**
  42836. * Defines a screen offset for the camera position.
  42837. */
  42838. targetScreenOffset: Vector2;
  42839. /**
  42840. * Allows the camera to be completely reversed.
  42841. * If false the camera can not arrive upside down.
  42842. */
  42843. allowUpsideDown: boolean;
  42844. /**
  42845. * Define if double tap/click is used to restore the previously saved state of the camera.
  42846. */
  42847. useInputToRestoreState: boolean;
  42848. /** @hidden */
  42849. _viewMatrix: Matrix;
  42850. /** @hidden */
  42851. _useCtrlForPanning: boolean;
  42852. /** @hidden */
  42853. _panningMouseButton: number;
  42854. /**
  42855. * Defines the input associated to the camera.
  42856. */
  42857. inputs: ArcRotateCameraInputsManager;
  42858. /** @hidden */
  42859. _reset: () => void;
  42860. /**
  42861. * Defines the allowed panning axis.
  42862. */
  42863. panningAxis: Vector3;
  42864. protected _localDirection: Vector3;
  42865. protected _transformedDirection: Vector3;
  42866. private _bouncingBehavior;
  42867. /**
  42868. * Gets the bouncing behavior of the camera if it has been enabled.
  42869. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42870. */
  42871. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42872. /**
  42873. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42874. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42875. */
  42876. get useBouncingBehavior(): boolean;
  42877. set useBouncingBehavior(value: boolean);
  42878. private _framingBehavior;
  42879. /**
  42880. * Gets the framing behavior of the camera if it has been enabled.
  42881. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42882. */
  42883. get framingBehavior(): Nullable<FramingBehavior>;
  42884. /**
  42885. * Defines if the framing behavior of the camera is enabled on the camera.
  42886. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42887. */
  42888. get useFramingBehavior(): boolean;
  42889. set useFramingBehavior(value: boolean);
  42890. private _autoRotationBehavior;
  42891. /**
  42892. * Gets the auto rotation behavior of the camera if it has been enabled.
  42893. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42894. */
  42895. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42896. /**
  42897. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42898. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42899. */
  42900. get useAutoRotationBehavior(): boolean;
  42901. set useAutoRotationBehavior(value: boolean);
  42902. /**
  42903. * Observable triggered when the mesh target has been changed on the camera.
  42904. */
  42905. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42906. /**
  42907. * Event raised when the camera is colliding with a mesh.
  42908. */
  42909. onCollide: (collidedMesh: AbstractMesh) => void;
  42910. /**
  42911. * Defines whether the camera should check collision with the objects oh the scene.
  42912. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42913. */
  42914. checkCollisions: boolean;
  42915. /**
  42916. * Defines the collision radius of the camera.
  42917. * This simulates a sphere around the camera.
  42918. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42919. */
  42920. collisionRadius: Vector3;
  42921. protected _collider: Collider;
  42922. protected _previousPosition: Vector3;
  42923. protected _collisionVelocity: Vector3;
  42924. protected _newPosition: Vector3;
  42925. protected _previousAlpha: number;
  42926. protected _previousBeta: number;
  42927. protected _previousRadius: number;
  42928. protected _collisionTriggered: boolean;
  42929. protected _targetBoundingCenter: Nullable<Vector3>;
  42930. private _computationVector;
  42931. /**
  42932. * Instantiates a new ArcRotateCamera in a given scene
  42933. * @param name Defines the name of the camera
  42934. * @param alpha Defines the camera rotation along the logitudinal axis
  42935. * @param beta Defines the camera rotation along the latitudinal axis
  42936. * @param radius Defines the camera distance from its target
  42937. * @param target Defines the camera target
  42938. * @param scene Defines the scene the camera belongs to
  42939. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42940. */
  42941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42942. /** @hidden */
  42943. _initCache(): void;
  42944. /** @hidden */
  42945. _updateCache(ignoreParentClass?: boolean): void;
  42946. protected _getTargetPosition(): Vector3;
  42947. private _storedAlpha;
  42948. private _storedBeta;
  42949. private _storedRadius;
  42950. private _storedTarget;
  42951. private _storedTargetScreenOffset;
  42952. /**
  42953. * Stores the current state of the camera (alpha, beta, radius and target)
  42954. * @returns the camera itself
  42955. */
  42956. storeState(): Camera;
  42957. /**
  42958. * @hidden
  42959. * Restored camera state. You must call storeState() first
  42960. */
  42961. _restoreStateValues(): boolean;
  42962. /** @hidden */
  42963. _isSynchronizedViewMatrix(): boolean;
  42964. /**
  42965. * Attached controls to the current camera.
  42966. * @param element Defines the element the controls should be listened from
  42967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42968. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42969. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42970. */
  42971. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42972. /**
  42973. * Detach the current controls from the camera.
  42974. * The camera will stop reacting to inputs.
  42975. * @param element Defines the element to stop listening the inputs from
  42976. */
  42977. detachControl(element: HTMLElement): void;
  42978. /** @hidden */
  42979. _checkInputs(): void;
  42980. protected _checkLimits(): void;
  42981. /**
  42982. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42983. */
  42984. rebuildAnglesAndRadius(): void;
  42985. /**
  42986. * Use a position to define the current camera related information like alpha, beta and radius
  42987. * @param position Defines the position to set the camera at
  42988. */
  42989. setPosition(position: Vector3): void;
  42990. /**
  42991. * Defines the target the camera should look at.
  42992. * This will automatically adapt alpha beta and radius to fit within the new target.
  42993. * @param target Defines the new target as a Vector or a mesh
  42994. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42995. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42996. */
  42997. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42998. /** @hidden */
  42999. _getViewMatrix(): Matrix;
  43000. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43001. /**
  43002. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43003. * @param meshes Defines the mesh to zoom on
  43004. * @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)
  43005. */
  43006. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43007. /**
  43008. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43009. * The target will be changed but the radius
  43010. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43011. * @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)
  43012. */
  43013. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43014. min: Vector3;
  43015. max: Vector3;
  43016. distance: number;
  43017. }, doNotUpdateMaxZ?: boolean): void;
  43018. /**
  43019. * @override
  43020. * Override Camera.createRigCamera
  43021. */
  43022. createRigCamera(name: string, cameraIndex: number): Camera;
  43023. /**
  43024. * @hidden
  43025. * @override
  43026. * Override Camera._updateRigCameras
  43027. */
  43028. _updateRigCameras(): void;
  43029. /**
  43030. * Destroy the camera and release the current resources hold by it.
  43031. */
  43032. dispose(): void;
  43033. /**
  43034. * Gets the current object class name.
  43035. * @return the class name
  43036. */
  43037. getClassName(): string;
  43038. }
  43039. }
  43040. declare module BABYLON {
  43041. /**
  43042. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43043. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43044. */
  43045. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43046. /**
  43047. * Gets the name of the behavior.
  43048. */
  43049. get name(): string;
  43050. private _zoomStopsAnimation;
  43051. private _idleRotationSpeed;
  43052. private _idleRotationWaitTime;
  43053. private _idleRotationSpinupTime;
  43054. /**
  43055. * Sets the flag that indicates if user zooming should stop animation.
  43056. */
  43057. set zoomStopsAnimation(flag: boolean);
  43058. /**
  43059. * Gets the flag that indicates if user zooming should stop animation.
  43060. */
  43061. get zoomStopsAnimation(): boolean;
  43062. /**
  43063. * Sets the default speed at which the camera rotates around the model.
  43064. */
  43065. set idleRotationSpeed(speed: number);
  43066. /**
  43067. * Gets the default speed at which the camera rotates around the model.
  43068. */
  43069. get idleRotationSpeed(): number;
  43070. /**
  43071. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43072. */
  43073. set idleRotationWaitTime(time: number);
  43074. /**
  43075. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43076. */
  43077. get idleRotationWaitTime(): number;
  43078. /**
  43079. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43080. */
  43081. set idleRotationSpinupTime(time: number);
  43082. /**
  43083. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43084. */
  43085. get idleRotationSpinupTime(): number;
  43086. /**
  43087. * Gets a value indicating if the camera is currently rotating because of this behavior
  43088. */
  43089. get rotationInProgress(): boolean;
  43090. private _onPrePointerObservableObserver;
  43091. private _onAfterCheckInputsObserver;
  43092. private _attachedCamera;
  43093. private _isPointerDown;
  43094. private _lastFrameTime;
  43095. private _lastInteractionTime;
  43096. private _cameraRotationSpeed;
  43097. /**
  43098. * Initializes the behavior.
  43099. */
  43100. init(): void;
  43101. /**
  43102. * Attaches the behavior to its arc rotate camera.
  43103. * @param camera Defines the camera to attach the behavior to
  43104. */
  43105. attach(camera: ArcRotateCamera): void;
  43106. /**
  43107. * Detaches the behavior from its current arc rotate camera.
  43108. */
  43109. detach(): void;
  43110. /**
  43111. * Returns true if user is scrolling.
  43112. * @return true if user is scrolling.
  43113. */
  43114. private _userIsZooming;
  43115. private _lastFrameRadius;
  43116. private _shouldAnimationStopForInteraction;
  43117. /**
  43118. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43119. */
  43120. private _applyUserInteraction;
  43121. private _userIsMoving;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43127. */
  43128. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43129. private ui;
  43130. /**
  43131. * The name of the behavior
  43132. */
  43133. name: string;
  43134. /**
  43135. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43136. */
  43137. distanceAwayFromFace: number;
  43138. /**
  43139. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43140. */
  43141. distanceAwayFromBottomOfFace: number;
  43142. private _faceVectors;
  43143. private _target;
  43144. private _scene;
  43145. private _onRenderObserver;
  43146. private _tmpMatrix;
  43147. private _tmpVector;
  43148. /**
  43149. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43150. * @param ui The transform node that should be attched to the mesh
  43151. */
  43152. constructor(ui: TransformNode);
  43153. /**
  43154. * Initializes the behavior
  43155. */
  43156. init(): void;
  43157. private _closestFace;
  43158. private _zeroVector;
  43159. private _lookAtTmpMatrix;
  43160. private _lookAtToRef;
  43161. /**
  43162. * Attaches the AttachToBoxBehavior to the passed in mesh
  43163. * @param target The mesh that the specified node will be attached to
  43164. */
  43165. attach(target: Mesh): void;
  43166. /**
  43167. * Detaches the behavior from the mesh
  43168. */
  43169. detach(): void;
  43170. }
  43171. }
  43172. declare module BABYLON {
  43173. /**
  43174. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43175. */
  43176. export class FadeInOutBehavior implements Behavior<Mesh> {
  43177. /**
  43178. * Time in milliseconds to delay before fading in (Default: 0)
  43179. */
  43180. delay: number;
  43181. /**
  43182. * Time in milliseconds for the mesh to fade in (Default: 300)
  43183. */
  43184. fadeInTime: number;
  43185. private _millisecondsPerFrame;
  43186. private _hovered;
  43187. private _hoverValue;
  43188. private _ownerNode;
  43189. /**
  43190. * Instatiates the FadeInOutBehavior
  43191. */
  43192. constructor();
  43193. /**
  43194. * The name of the behavior
  43195. */
  43196. get name(): string;
  43197. /**
  43198. * Initializes the behavior
  43199. */
  43200. init(): void;
  43201. /**
  43202. * Attaches the fade behavior on the passed in mesh
  43203. * @param ownerNode The mesh that will be faded in/out once attached
  43204. */
  43205. attach(ownerNode: Mesh): void;
  43206. /**
  43207. * Detaches the behavior from the mesh
  43208. */
  43209. detach(): void;
  43210. /**
  43211. * Triggers the mesh to begin fading in or out
  43212. * @param value if the object should fade in or out (true to fade in)
  43213. */
  43214. fadeIn(value: boolean): void;
  43215. private _update;
  43216. private _setAllVisibility;
  43217. }
  43218. }
  43219. declare module BABYLON {
  43220. /**
  43221. * Class containing a set of static utilities functions for managing Pivots
  43222. * @hidden
  43223. */
  43224. export class PivotTools {
  43225. private static _PivotCached;
  43226. private static _OldPivotPoint;
  43227. private static _PivotTranslation;
  43228. private static _PivotTmpVector;
  43229. /** @hidden */
  43230. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43231. /** @hidden */
  43232. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Class containing static functions to help procedurally build meshes
  43238. */
  43239. export class PlaneBuilder {
  43240. /**
  43241. * Creates a plane mesh
  43242. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43243. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43244. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43246. * * 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
  43247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43248. * @param name defines the name of the mesh
  43249. * @param options defines the options used to create the mesh
  43250. * @param scene defines the hosting scene
  43251. * @returns the plane mesh
  43252. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43253. */
  43254. static CreatePlane(name: string, options: {
  43255. size?: number;
  43256. width?: number;
  43257. height?: number;
  43258. sideOrientation?: number;
  43259. frontUVs?: Vector4;
  43260. backUVs?: Vector4;
  43261. updatable?: boolean;
  43262. sourcePlane?: Plane;
  43263. }, scene?: Nullable<Scene>): Mesh;
  43264. }
  43265. }
  43266. declare module BABYLON {
  43267. /**
  43268. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43269. */
  43270. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43271. private static _AnyMouseID;
  43272. /**
  43273. * Abstract mesh the behavior is set on
  43274. */
  43275. attachedNode: AbstractMesh;
  43276. private _dragPlane;
  43277. private _scene;
  43278. private _pointerObserver;
  43279. private _beforeRenderObserver;
  43280. private static _planeScene;
  43281. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43282. /**
  43283. * 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)
  43284. */
  43285. maxDragAngle: number;
  43286. /**
  43287. * @hidden
  43288. */
  43289. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43290. /**
  43291. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43292. */
  43293. currentDraggingPointerID: number;
  43294. /**
  43295. * The last position where the pointer hit the drag plane in world space
  43296. */
  43297. lastDragPosition: Vector3;
  43298. /**
  43299. * If the behavior is currently in a dragging state
  43300. */
  43301. dragging: boolean;
  43302. /**
  43303. * 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)
  43304. */
  43305. dragDeltaRatio: number;
  43306. /**
  43307. * If the drag plane orientation should be updated during the dragging (Default: true)
  43308. */
  43309. updateDragPlane: boolean;
  43310. private _debugMode;
  43311. private _moving;
  43312. /**
  43313. * Fires each time the attached mesh is dragged with the pointer
  43314. * * delta between last drag position and current drag position in world space
  43315. * * dragDistance along the drag axis
  43316. * * dragPlaneNormal normal of the current drag plane used during the drag
  43317. * * dragPlanePoint in world space where the drag intersects the drag plane
  43318. */
  43319. onDragObservable: Observable<{
  43320. delta: Vector3;
  43321. dragPlanePoint: Vector3;
  43322. dragPlaneNormal: Vector3;
  43323. dragDistance: number;
  43324. pointerId: number;
  43325. }>;
  43326. /**
  43327. * Fires each time a drag begins (eg. mouse down on mesh)
  43328. */
  43329. onDragStartObservable: Observable<{
  43330. dragPlanePoint: Vector3;
  43331. pointerId: number;
  43332. }>;
  43333. /**
  43334. * Fires each time a drag ends (eg. mouse release after drag)
  43335. */
  43336. onDragEndObservable: Observable<{
  43337. dragPlanePoint: Vector3;
  43338. pointerId: number;
  43339. }>;
  43340. /**
  43341. * If the attached mesh should be moved when dragged
  43342. */
  43343. moveAttached: boolean;
  43344. /**
  43345. * If the drag behavior will react to drag events (Default: true)
  43346. */
  43347. enabled: boolean;
  43348. /**
  43349. * If pointer events should start and release the drag (Default: true)
  43350. */
  43351. startAndReleaseDragOnPointerEvents: boolean;
  43352. /**
  43353. * If camera controls should be detached during the drag
  43354. */
  43355. detachCameraControls: boolean;
  43356. /**
  43357. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43358. */
  43359. useObjectOrientationForDragging: boolean;
  43360. private _options;
  43361. /**
  43362. * Gets the options used by the behavior
  43363. */
  43364. get options(): {
  43365. dragAxis?: Vector3;
  43366. dragPlaneNormal?: Vector3;
  43367. };
  43368. /**
  43369. * Sets the options used by the behavior
  43370. */
  43371. set options(options: {
  43372. dragAxis?: Vector3;
  43373. dragPlaneNormal?: Vector3;
  43374. });
  43375. /**
  43376. * Creates a pointer drag behavior that can be attached to a mesh
  43377. * @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)
  43378. */
  43379. constructor(options?: {
  43380. dragAxis?: Vector3;
  43381. dragPlaneNormal?: Vector3;
  43382. });
  43383. /**
  43384. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43385. */
  43386. validateDrag: (targetPosition: Vector3) => boolean;
  43387. /**
  43388. * The name of the behavior
  43389. */
  43390. get name(): string;
  43391. /**
  43392. * Initializes the behavior
  43393. */
  43394. init(): void;
  43395. private _tmpVector;
  43396. private _alternatePickedPoint;
  43397. private _worldDragAxis;
  43398. private _targetPosition;
  43399. private _attachedElement;
  43400. /**
  43401. * Attaches the drag behavior the passed in mesh
  43402. * @param ownerNode The mesh that will be dragged around once attached
  43403. * @param predicate Predicate to use for pick filtering
  43404. */
  43405. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43406. /**
  43407. * Force relase the drag action by code.
  43408. */
  43409. releaseDrag(): void;
  43410. private _startDragRay;
  43411. private _lastPointerRay;
  43412. /**
  43413. * Simulates the start of a pointer drag event on the behavior
  43414. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43415. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43416. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43417. */
  43418. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43419. private _startDrag;
  43420. private _dragDelta;
  43421. private _moveDrag;
  43422. private _pickWithRayOnDragPlane;
  43423. private _pointA;
  43424. private _pointC;
  43425. private _localAxis;
  43426. private _lookAt;
  43427. private _updateDragPlanePosition;
  43428. /**
  43429. * Detaches the behavior from the mesh
  43430. */
  43431. detach(): void;
  43432. }
  43433. }
  43434. declare module BABYLON {
  43435. /**
  43436. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43437. */
  43438. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43439. private _dragBehaviorA;
  43440. private _dragBehaviorB;
  43441. private _startDistance;
  43442. private _initialScale;
  43443. private _targetScale;
  43444. private _ownerNode;
  43445. private _sceneRenderObserver;
  43446. /**
  43447. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43448. */
  43449. constructor();
  43450. /**
  43451. * The name of the behavior
  43452. */
  43453. get name(): string;
  43454. /**
  43455. * Initializes the behavior
  43456. */
  43457. init(): void;
  43458. private _getCurrentDistance;
  43459. /**
  43460. * Attaches the scale behavior the passed in mesh
  43461. * @param ownerNode The mesh that will be scaled around once attached
  43462. */
  43463. attach(ownerNode: Mesh): void;
  43464. /**
  43465. * Detaches the behavior from the mesh
  43466. */
  43467. detach(): void;
  43468. }
  43469. }
  43470. declare module BABYLON {
  43471. /**
  43472. * 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
  43473. */
  43474. export class SixDofDragBehavior implements Behavior<Mesh> {
  43475. private static _virtualScene;
  43476. private _ownerNode;
  43477. private _sceneRenderObserver;
  43478. private _scene;
  43479. private _targetPosition;
  43480. private _virtualOriginMesh;
  43481. private _virtualDragMesh;
  43482. private _pointerObserver;
  43483. private _moving;
  43484. private _startingOrientation;
  43485. private _attachedElement;
  43486. /**
  43487. * 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)
  43488. */
  43489. private zDragFactor;
  43490. /**
  43491. * If the object should rotate to face the drag origin
  43492. */
  43493. rotateDraggedObject: boolean;
  43494. /**
  43495. * If the behavior is currently in a dragging state
  43496. */
  43497. dragging: boolean;
  43498. /**
  43499. * 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)
  43500. */
  43501. dragDeltaRatio: number;
  43502. /**
  43503. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43504. */
  43505. currentDraggingPointerID: number;
  43506. /**
  43507. * If camera controls should be detached during the drag
  43508. */
  43509. detachCameraControls: boolean;
  43510. /**
  43511. * Fires each time a drag starts
  43512. */
  43513. onDragStartObservable: Observable<{}>;
  43514. /**
  43515. * Fires each time a drag ends (eg. mouse release after drag)
  43516. */
  43517. onDragEndObservable: Observable<{}>;
  43518. /**
  43519. * 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
  43520. */
  43521. constructor();
  43522. /**
  43523. * The name of the behavior
  43524. */
  43525. get name(): string;
  43526. /**
  43527. * Initializes the behavior
  43528. */
  43529. init(): void;
  43530. /**
  43531. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43532. */
  43533. private get _pointerCamera();
  43534. /**
  43535. * Attaches the scale behavior the passed in mesh
  43536. * @param ownerNode The mesh that will be scaled around once attached
  43537. */
  43538. attach(ownerNode: Mesh): void;
  43539. /**
  43540. * Detaches the behavior from the mesh
  43541. */
  43542. detach(): void;
  43543. }
  43544. }
  43545. declare module BABYLON {
  43546. /**
  43547. * Class used to apply inverse kinematics to bones
  43548. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43549. */
  43550. export class BoneIKController {
  43551. private static _tmpVecs;
  43552. private static _tmpQuat;
  43553. private static _tmpMats;
  43554. /**
  43555. * Gets or sets the target mesh
  43556. */
  43557. targetMesh: AbstractMesh;
  43558. /** Gets or sets the mesh used as pole */
  43559. poleTargetMesh: AbstractMesh;
  43560. /**
  43561. * Gets or sets the bone used as pole
  43562. */
  43563. poleTargetBone: Nullable<Bone>;
  43564. /**
  43565. * Gets or sets the target position
  43566. */
  43567. targetPosition: Vector3;
  43568. /**
  43569. * Gets or sets the pole target position
  43570. */
  43571. poleTargetPosition: Vector3;
  43572. /**
  43573. * Gets or sets the pole target local offset
  43574. */
  43575. poleTargetLocalOffset: Vector3;
  43576. /**
  43577. * Gets or sets the pole angle
  43578. */
  43579. poleAngle: number;
  43580. /**
  43581. * Gets or sets the mesh associated with the controller
  43582. */
  43583. mesh: AbstractMesh;
  43584. /**
  43585. * 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)
  43586. */
  43587. slerpAmount: number;
  43588. private _bone1Quat;
  43589. private _bone1Mat;
  43590. private _bone2Ang;
  43591. private _bone1;
  43592. private _bone2;
  43593. private _bone1Length;
  43594. private _bone2Length;
  43595. private _maxAngle;
  43596. private _maxReach;
  43597. private _rightHandedSystem;
  43598. private _bendAxis;
  43599. private _slerping;
  43600. private _adjustRoll;
  43601. /**
  43602. * Gets or sets maximum allowed angle
  43603. */
  43604. get maxAngle(): number;
  43605. set maxAngle(value: number);
  43606. /**
  43607. * Creates a new BoneIKController
  43608. * @param mesh defines the mesh to control
  43609. * @param bone defines the bone to control
  43610. * @param options defines options to set up the controller
  43611. */
  43612. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43613. targetMesh?: AbstractMesh;
  43614. poleTargetMesh?: AbstractMesh;
  43615. poleTargetBone?: Bone;
  43616. poleTargetLocalOffset?: Vector3;
  43617. poleAngle?: number;
  43618. bendAxis?: Vector3;
  43619. maxAngle?: number;
  43620. slerpAmount?: number;
  43621. });
  43622. private _setMaxAngle;
  43623. /**
  43624. * Force the controller to update the bones
  43625. */
  43626. update(): void;
  43627. }
  43628. }
  43629. declare module BABYLON {
  43630. /**
  43631. * Class used to make a bone look toward a point in space
  43632. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43633. */
  43634. export class BoneLookController {
  43635. private static _tmpVecs;
  43636. private static _tmpQuat;
  43637. private static _tmpMats;
  43638. /**
  43639. * The target Vector3 that the bone will look at
  43640. */
  43641. target: Vector3;
  43642. /**
  43643. * The mesh that the bone is attached to
  43644. */
  43645. mesh: AbstractMesh;
  43646. /**
  43647. * The bone that will be looking to the target
  43648. */
  43649. bone: Bone;
  43650. /**
  43651. * The up axis of the coordinate system that is used when the bone is rotated
  43652. */
  43653. upAxis: Vector3;
  43654. /**
  43655. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43656. */
  43657. upAxisSpace: Space;
  43658. /**
  43659. * Used to make an adjustment to the yaw of the bone
  43660. */
  43661. adjustYaw: number;
  43662. /**
  43663. * Used to make an adjustment to the pitch of the bone
  43664. */
  43665. adjustPitch: number;
  43666. /**
  43667. * Used to make an adjustment to the roll of the bone
  43668. */
  43669. adjustRoll: number;
  43670. /**
  43671. * 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)
  43672. */
  43673. slerpAmount: number;
  43674. private _minYaw;
  43675. private _maxYaw;
  43676. private _minPitch;
  43677. private _maxPitch;
  43678. private _minYawSin;
  43679. private _minYawCos;
  43680. private _maxYawSin;
  43681. private _maxYawCos;
  43682. private _midYawConstraint;
  43683. private _minPitchTan;
  43684. private _maxPitchTan;
  43685. private _boneQuat;
  43686. private _slerping;
  43687. private _transformYawPitch;
  43688. private _transformYawPitchInv;
  43689. private _firstFrameSkipped;
  43690. private _yawRange;
  43691. private _fowardAxis;
  43692. /**
  43693. * Gets or sets the minimum yaw angle that the bone can look to
  43694. */
  43695. get minYaw(): number;
  43696. set minYaw(value: number);
  43697. /**
  43698. * Gets or sets the maximum yaw angle that the bone can look to
  43699. */
  43700. get maxYaw(): number;
  43701. set maxYaw(value: number);
  43702. /**
  43703. * Gets or sets the minimum pitch angle that the bone can look to
  43704. */
  43705. get minPitch(): number;
  43706. set minPitch(value: number);
  43707. /**
  43708. * Gets or sets the maximum pitch angle that the bone can look to
  43709. */
  43710. get maxPitch(): number;
  43711. set maxPitch(value: number);
  43712. /**
  43713. * Create a BoneLookController
  43714. * @param mesh the mesh that the bone belongs to
  43715. * @param bone the bone that will be looking to the target
  43716. * @param target the target Vector3 to look at
  43717. * @param options optional settings:
  43718. * * maxYaw: the maximum angle the bone will yaw to
  43719. * * minYaw: the minimum angle the bone will yaw to
  43720. * * maxPitch: the maximum angle the bone will pitch to
  43721. * * minPitch: the minimum angle the bone will yaw to
  43722. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43723. * * upAxis: the up axis of the coordinate system
  43724. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43725. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43726. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43727. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43728. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43729. * * adjustRoll: used to make an adjustment to the roll of the bone
  43730. **/
  43731. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43732. maxYaw?: number;
  43733. minYaw?: number;
  43734. maxPitch?: number;
  43735. minPitch?: number;
  43736. slerpAmount?: number;
  43737. upAxis?: Vector3;
  43738. upAxisSpace?: Space;
  43739. yawAxis?: Vector3;
  43740. pitchAxis?: Vector3;
  43741. adjustYaw?: number;
  43742. adjustPitch?: number;
  43743. adjustRoll?: number;
  43744. });
  43745. /**
  43746. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43747. */
  43748. update(): void;
  43749. private _getAngleDiff;
  43750. private _getAngleBetween;
  43751. private _isAngleBetween;
  43752. }
  43753. }
  43754. declare module BABYLON {
  43755. /**
  43756. * Manage the gamepad inputs to control an arc rotate camera.
  43757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43758. */
  43759. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43760. /**
  43761. * Defines the camera the input is attached to.
  43762. */
  43763. camera: ArcRotateCamera;
  43764. /**
  43765. * Defines the gamepad the input is gathering event from.
  43766. */
  43767. gamepad: Nullable<Gamepad>;
  43768. /**
  43769. * Defines the gamepad rotation sensiblity.
  43770. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43771. */
  43772. gamepadRotationSensibility: number;
  43773. /**
  43774. * Defines the gamepad move sensiblity.
  43775. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43776. */
  43777. gamepadMoveSensibility: number;
  43778. private _yAxisScale;
  43779. /**
  43780. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43781. */
  43782. get invertYAxis(): boolean;
  43783. set invertYAxis(value: boolean);
  43784. private _onGamepadConnectedObserver;
  43785. private _onGamepadDisconnectedObserver;
  43786. /**
  43787. * Attach the input controls to a specific dom element to get the input from.
  43788. * @param element Defines the element the controls should be listened from
  43789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43790. */
  43791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43792. /**
  43793. * Detach the current controls from the specified dom element.
  43794. * @param element Defines the element to stop listening the inputs from
  43795. */
  43796. detachControl(element: Nullable<HTMLElement>): void;
  43797. /**
  43798. * Update the current camera state depending on the inputs that have been used this frame.
  43799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43800. */
  43801. checkInputs(): void;
  43802. /**
  43803. * Gets the class name of the current intput.
  43804. * @returns the class name
  43805. */
  43806. getClassName(): string;
  43807. /**
  43808. * Get the friendly name associated with the input class.
  43809. * @returns the input friendly name
  43810. */
  43811. getSimpleName(): string;
  43812. }
  43813. }
  43814. declare module BABYLON {
  43815. interface ArcRotateCameraInputsManager {
  43816. /**
  43817. * Add orientation input support to the input manager.
  43818. * @returns the current input manager
  43819. */
  43820. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43821. }
  43822. /**
  43823. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43824. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43825. */
  43826. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43827. /**
  43828. * Defines the camera the input is attached to.
  43829. */
  43830. camera: ArcRotateCamera;
  43831. /**
  43832. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43833. */
  43834. alphaCorrection: number;
  43835. /**
  43836. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43837. */
  43838. gammaCorrection: number;
  43839. private _alpha;
  43840. private _gamma;
  43841. private _dirty;
  43842. private _deviceOrientationHandler;
  43843. /**
  43844. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43845. */
  43846. constructor();
  43847. /**
  43848. * Attach the input controls to a specific dom element to get the input from.
  43849. * @param element Defines the element the controls should be listened from
  43850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43851. */
  43852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43853. /** @hidden */
  43854. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43855. /**
  43856. * Update the current camera state depending on the inputs that have been used this frame.
  43857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43858. */
  43859. checkInputs(): void;
  43860. /**
  43861. * Detach the current controls from the specified dom element.
  43862. * @param element Defines the element to stop listening the inputs from
  43863. */
  43864. detachControl(element: Nullable<HTMLElement>): void;
  43865. /**
  43866. * Gets the class name of the current intput.
  43867. * @returns the class name
  43868. */
  43869. getClassName(): string;
  43870. /**
  43871. * Get the friendly name associated with the input class.
  43872. * @returns the input friendly name
  43873. */
  43874. getSimpleName(): string;
  43875. }
  43876. }
  43877. declare module BABYLON {
  43878. /**
  43879. * Listen to mouse events to control the camera.
  43880. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43881. */
  43882. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43883. /**
  43884. * Defines the camera the input is attached to.
  43885. */
  43886. camera: FlyCamera;
  43887. /**
  43888. * Defines if touch is enabled. (Default is true.)
  43889. */
  43890. touchEnabled: boolean;
  43891. /**
  43892. * Defines the buttons associated with the input to handle camera rotation.
  43893. */
  43894. buttons: number[];
  43895. /**
  43896. * Assign buttons for Yaw control.
  43897. */
  43898. buttonsYaw: number[];
  43899. /**
  43900. * Assign buttons for Pitch control.
  43901. */
  43902. buttonsPitch: number[];
  43903. /**
  43904. * Assign buttons for Roll control.
  43905. */
  43906. buttonsRoll: number[];
  43907. /**
  43908. * Detect if any button is being pressed while mouse is moved.
  43909. * -1 = Mouse locked.
  43910. * 0 = Left button.
  43911. * 1 = Middle Button.
  43912. * 2 = Right Button.
  43913. */
  43914. activeButton: number;
  43915. /**
  43916. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43917. * Higher values reduce its sensitivity.
  43918. */
  43919. angularSensibility: number;
  43920. private _mousemoveCallback;
  43921. private _observer;
  43922. private _rollObserver;
  43923. private previousPosition;
  43924. private noPreventDefault;
  43925. private element;
  43926. /**
  43927. * Listen to mouse events to control the camera.
  43928. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43930. */
  43931. constructor(touchEnabled?: boolean);
  43932. /**
  43933. * Attach the mouse control to the HTML DOM element.
  43934. * @param element Defines the element that listens to the input events.
  43935. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43936. */
  43937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43938. /**
  43939. * Detach the current controls from the specified dom element.
  43940. * @param element Defines the element to stop listening the inputs from
  43941. */
  43942. detachControl(element: Nullable<HTMLElement>): void;
  43943. /**
  43944. * Gets the class name of the current input.
  43945. * @returns the class name.
  43946. */
  43947. getClassName(): string;
  43948. /**
  43949. * Get the friendly name associated with the input class.
  43950. * @returns the input's friendly name.
  43951. */
  43952. getSimpleName(): string;
  43953. private _pointerInput;
  43954. private _onMouseMove;
  43955. /**
  43956. * Rotate camera by mouse offset.
  43957. */
  43958. private rotateCamera;
  43959. }
  43960. }
  43961. declare module BABYLON {
  43962. /**
  43963. * Default Inputs manager for the FlyCamera.
  43964. * It groups all the default supported inputs for ease of use.
  43965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43966. */
  43967. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43968. /**
  43969. * Instantiates a new FlyCameraInputsManager.
  43970. * @param camera Defines the camera the inputs belong to.
  43971. */
  43972. constructor(camera: FlyCamera);
  43973. /**
  43974. * Add keyboard input support to the input manager.
  43975. * @returns the new FlyCameraKeyboardMoveInput().
  43976. */
  43977. addKeyboard(): FlyCameraInputsManager;
  43978. /**
  43979. * Add mouse input support to the input manager.
  43980. * @param touchEnabled Enable touch screen support.
  43981. * @returns the new FlyCameraMouseInput().
  43982. */
  43983. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43984. }
  43985. }
  43986. declare module BABYLON {
  43987. /**
  43988. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43989. * such as in a 3D Space Shooter or a Flight Simulator.
  43990. */
  43991. export class FlyCamera extends TargetCamera {
  43992. /**
  43993. * Define the collision ellipsoid of the camera.
  43994. * This is helpful for simulating a camera body, like a player's body.
  43995. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43996. */
  43997. ellipsoid: Vector3;
  43998. /**
  43999. * Define an offset for the position of the ellipsoid around the camera.
  44000. * This can be helpful if the camera is attached away from the player's body center,
  44001. * such as at its head.
  44002. */
  44003. ellipsoidOffset: Vector3;
  44004. /**
  44005. * Enable or disable collisions of the camera with the rest of the scene objects.
  44006. */
  44007. checkCollisions: boolean;
  44008. /**
  44009. * Enable or disable gravity on the camera.
  44010. */
  44011. applyGravity: boolean;
  44012. /**
  44013. * Define the current direction the camera is moving to.
  44014. */
  44015. cameraDirection: Vector3;
  44016. /**
  44017. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44018. * This overrides and empties cameraRotation.
  44019. */
  44020. rotationQuaternion: Quaternion;
  44021. /**
  44022. * Track Roll to maintain the wanted Rolling when looking around.
  44023. */
  44024. _trackRoll: number;
  44025. /**
  44026. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44027. */
  44028. rollCorrect: number;
  44029. /**
  44030. * Mimic a banked turn, Rolling the camera when Yawing.
  44031. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44032. */
  44033. bankedTurn: boolean;
  44034. /**
  44035. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44036. */
  44037. bankedTurnLimit: number;
  44038. /**
  44039. * Value of 0 disables the banked Roll.
  44040. * Value of 1 is equal to the Yaw angle in radians.
  44041. */
  44042. bankedTurnMultiplier: number;
  44043. /**
  44044. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44045. */
  44046. inputs: FlyCameraInputsManager;
  44047. /**
  44048. * Gets the input sensibility for mouse input.
  44049. * Higher values reduce sensitivity.
  44050. */
  44051. get angularSensibility(): number;
  44052. /**
  44053. * Sets the input sensibility for a mouse input.
  44054. * Higher values reduce sensitivity.
  44055. */
  44056. set angularSensibility(value: number);
  44057. /**
  44058. * Get the keys for camera movement forward.
  44059. */
  44060. get keysForward(): number[];
  44061. /**
  44062. * Set the keys for camera movement forward.
  44063. */
  44064. set keysForward(value: number[]);
  44065. /**
  44066. * Get the keys for camera movement backward.
  44067. */
  44068. get keysBackward(): number[];
  44069. set keysBackward(value: number[]);
  44070. /**
  44071. * Get the keys for camera movement up.
  44072. */
  44073. get keysUp(): number[];
  44074. /**
  44075. * Set the keys for camera movement up.
  44076. */
  44077. set keysUp(value: number[]);
  44078. /**
  44079. * Get the keys for camera movement down.
  44080. */
  44081. get keysDown(): number[];
  44082. /**
  44083. * Set the keys for camera movement down.
  44084. */
  44085. set keysDown(value: number[]);
  44086. /**
  44087. * Get the keys for camera movement left.
  44088. */
  44089. get keysLeft(): number[];
  44090. /**
  44091. * Set the keys for camera movement left.
  44092. */
  44093. set keysLeft(value: number[]);
  44094. /**
  44095. * Set the keys for camera movement right.
  44096. */
  44097. get keysRight(): number[];
  44098. /**
  44099. * Set the keys for camera movement right.
  44100. */
  44101. set keysRight(value: number[]);
  44102. /**
  44103. * Event raised when the camera collides with a mesh in the scene.
  44104. */
  44105. onCollide: (collidedMesh: AbstractMesh) => void;
  44106. private _collider;
  44107. private _needMoveForGravity;
  44108. private _oldPosition;
  44109. private _diffPosition;
  44110. private _newPosition;
  44111. /** @hidden */
  44112. _localDirection: Vector3;
  44113. /** @hidden */
  44114. _transformedDirection: Vector3;
  44115. /**
  44116. * Instantiates a FlyCamera.
  44117. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44118. * such as in a 3D Space Shooter or a Flight Simulator.
  44119. * @param name Define the name of the camera in the scene.
  44120. * @param position Define the starting position of the camera in the scene.
  44121. * @param scene Define the scene the camera belongs to.
  44122. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44123. */
  44124. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44125. /**
  44126. * Attach a control to the HTML DOM element.
  44127. * @param element Defines the element that listens to the input events.
  44128. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44129. */
  44130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44131. /**
  44132. * Detach a control from the HTML DOM element.
  44133. * The camera will stop reacting to that input.
  44134. * @param element Defines the element that listens to the input events.
  44135. */
  44136. detachControl(element: HTMLElement): void;
  44137. private _collisionMask;
  44138. /**
  44139. * Get the mask that the camera ignores in collision events.
  44140. */
  44141. get collisionMask(): number;
  44142. /**
  44143. * Set the mask that the camera ignores in collision events.
  44144. */
  44145. set collisionMask(mask: number);
  44146. /** @hidden */
  44147. _collideWithWorld(displacement: Vector3): void;
  44148. /** @hidden */
  44149. private _onCollisionPositionChange;
  44150. /** @hidden */
  44151. _checkInputs(): void;
  44152. /** @hidden */
  44153. _decideIfNeedsToMove(): boolean;
  44154. /** @hidden */
  44155. _updatePosition(): void;
  44156. /**
  44157. * Restore the Roll to its target value at the rate specified.
  44158. * @param rate - Higher means slower restoring.
  44159. * @hidden
  44160. */
  44161. restoreRoll(rate: number): void;
  44162. /**
  44163. * Destroy the camera and release the current resources held by it.
  44164. */
  44165. dispose(): void;
  44166. /**
  44167. * Get the current object class name.
  44168. * @returns the class name.
  44169. */
  44170. getClassName(): string;
  44171. }
  44172. }
  44173. declare module BABYLON {
  44174. /**
  44175. * Listen to keyboard events to control the camera.
  44176. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44177. */
  44178. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44179. /**
  44180. * Defines the camera the input is attached to.
  44181. */
  44182. camera: FlyCamera;
  44183. /**
  44184. * The list of keyboard keys used to control the forward move of the camera.
  44185. */
  44186. keysForward: number[];
  44187. /**
  44188. * The list of keyboard keys used to control the backward move of the camera.
  44189. */
  44190. keysBackward: number[];
  44191. /**
  44192. * The list of keyboard keys used to control the forward move of the camera.
  44193. */
  44194. keysUp: number[];
  44195. /**
  44196. * The list of keyboard keys used to control the backward move of the camera.
  44197. */
  44198. keysDown: number[];
  44199. /**
  44200. * The list of keyboard keys used to control the right strafe move of the camera.
  44201. */
  44202. keysRight: number[];
  44203. /**
  44204. * The list of keyboard keys used to control the left strafe move of the camera.
  44205. */
  44206. keysLeft: number[];
  44207. private _keys;
  44208. private _onCanvasBlurObserver;
  44209. private _onKeyboardObserver;
  44210. private _engine;
  44211. private _scene;
  44212. /**
  44213. * Attach the input controls to a specific dom element to get the input from.
  44214. * @param element Defines the element the controls should be listened from
  44215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44216. */
  44217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44218. /**
  44219. * Detach the current controls from the specified dom element.
  44220. * @param element Defines the element to stop listening the inputs from
  44221. */
  44222. detachControl(element: Nullable<HTMLElement>): void;
  44223. /**
  44224. * Gets the class name of the current intput.
  44225. * @returns the class name
  44226. */
  44227. getClassName(): string;
  44228. /** @hidden */
  44229. _onLostFocus(e: FocusEvent): void;
  44230. /**
  44231. * Get the friendly name associated with the input class.
  44232. * @returns the input friendly name
  44233. */
  44234. getSimpleName(): string;
  44235. /**
  44236. * Update the current camera state depending on the inputs that have been used this frame.
  44237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44238. */
  44239. checkInputs(): void;
  44240. }
  44241. }
  44242. declare module BABYLON {
  44243. /**
  44244. * Manage the mouse wheel inputs to control a follow camera.
  44245. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44246. */
  44247. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44248. /**
  44249. * Defines the camera the input is attached to.
  44250. */
  44251. camera: FollowCamera;
  44252. /**
  44253. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44254. */
  44255. axisControlRadius: boolean;
  44256. /**
  44257. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44258. */
  44259. axisControlHeight: boolean;
  44260. /**
  44261. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44262. */
  44263. axisControlRotation: boolean;
  44264. /**
  44265. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44266. * relation to mouseWheel events.
  44267. */
  44268. wheelPrecision: number;
  44269. /**
  44270. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44271. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44272. */
  44273. wheelDeltaPercentage: number;
  44274. private _wheel;
  44275. private _observer;
  44276. /**
  44277. * Attach the input controls to a specific dom element to get the input from.
  44278. * @param element Defines the element the controls should be listened from
  44279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44280. */
  44281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44282. /**
  44283. * Detach the current controls from the specified dom element.
  44284. * @param element Defines the element to stop listening the inputs from
  44285. */
  44286. detachControl(element: Nullable<HTMLElement>): void;
  44287. /**
  44288. * Gets the class name of the current intput.
  44289. * @returns the class name
  44290. */
  44291. getClassName(): string;
  44292. /**
  44293. * Get the friendly name associated with the input class.
  44294. * @returns the input friendly name
  44295. */
  44296. getSimpleName(): string;
  44297. }
  44298. }
  44299. declare module BABYLON {
  44300. /**
  44301. * Manage the pointers inputs to control an follow camera.
  44302. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44303. */
  44304. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44305. /**
  44306. * Defines the camera the input is attached to.
  44307. */
  44308. camera: FollowCamera;
  44309. /**
  44310. * Gets the class name of the current input.
  44311. * @returns the class name
  44312. */
  44313. getClassName(): string;
  44314. /**
  44315. * Defines the pointer angular sensibility along the X axis or how fast is
  44316. * the camera rotating.
  44317. * A negative number will reverse the axis direction.
  44318. */
  44319. angularSensibilityX: number;
  44320. /**
  44321. * Defines the pointer angular sensibility along the Y axis or how fast is
  44322. * the camera rotating.
  44323. * A negative number will reverse the axis direction.
  44324. */
  44325. angularSensibilityY: number;
  44326. /**
  44327. * Defines the pointer pinch precision or how fast is the camera zooming.
  44328. * A negative number will reverse the axis direction.
  44329. */
  44330. pinchPrecision: number;
  44331. /**
  44332. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44333. * from 0.
  44334. * It defines the percentage of current camera.radius to use as delta when
  44335. * pinch zoom is used.
  44336. */
  44337. pinchDeltaPercentage: number;
  44338. /**
  44339. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44340. */
  44341. axisXControlRadius: boolean;
  44342. /**
  44343. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44344. */
  44345. axisXControlHeight: boolean;
  44346. /**
  44347. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44348. */
  44349. axisXControlRotation: boolean;
  44350. /**
  44351. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44352. */
  44353. axisYControlRadius: boolean;
  44354. /**
  44355. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44356. */
  44357. axisYControlHeight: boolean;
  44358. /**
  44359. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44360. */
  44361. axisYControlRotation: boolean;
  44362. /**
  44363. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44364. */
  44365. axisPinchControlRadius: boolean;
  44366. /**
  44367. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44368. */
  44369. axisPinchControlHeight: boolean;
  44370. /**
  44371. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44372. */
  44373. axisPinchControlRotation: boolean;
  44374. /**
  44375. * Log error messages if basic misconfiguration has occurred.
  44376. */
  44377. warningEnable: boolean;
  44378. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44379. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44380. private _warningCounter;
  44381. private _warning;
  44382. }
  44383. }
  44384. declare module BABYLON {
  44385. /**
  44386. * Default Inputs manager for the FollowCamera.
  44387. * It groups all the default supported inputs for ease of use.
  44388. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44389. */
  44390. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44391. /**
  44392. * Instantiates a new FollowCameraInputsManager.
  44393. * @param camera Defines the camera the inputs belong to
  44394. */
  44395. constructor(camera: FollowCamera);
  44396. /**
  44397. * Add keyboard input support to the input manager.
  44398. * @returns the current input manager
  44399. */
  44400. addKeyboard(): FollowCameraInputsManager;
  44401. /**
  44402. * Add mouse wheel input support to the input manager.
  44403. * @returns the current input manager
  44404. */
  44405. addMouseWheel(): FollowCameraInputsManager;
  44406. /**
  44407. * Add pointers input support to the input manager.
  44408. * @returns the current input manager
  44409. */
  44410. addPointers(): FollowCameraInputsManager;
  44411. /**
  44412. * Add orientation input support to the input manager.
  44413. * @returns the current input manager
  44414. */
  44415. addVRDeviceOrientation(): FollowCameraInputsManager;
  44416. }
  44417. }
  44418. declare module BABYLON {
  44419. /**
  44420. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44421. * an arc rotate version arcFollowCamera are available.
  44422. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44423. */
  44424. export class FollowCamera extends TargetCamera {
  44425. /**
  44426. * Distance the follow camera should follow an object at
  44427. */
  44428. radius: number;
  44429. /**
  44430. * Minimum allowed distance of the camera to the axis of rotation
  44431. * (The camera can not get closer).
  44432. * This can help limiting how the Camera is able to move in the scene.
  44433. */
  44434. lowerRadiusLimit: Nullable<number>;
  44435. /**
  44436. * Maximum allowed distance of the camera to the axis of rotation
  44437. * (The camera can not get further).
  44438. * This can help limiting how the Camera is able to move in the scene.
  44439. */
  44440. upperRadiusLimit: Nullable<number>;
  44441. /**
  44442. * Define a rotation offset between the camera and the object it follows
  44443. */
  44444. rotationOffset: number;
  44445. /**
  44446. * Minimum allowed angle to camera position relative to target object.
  44447. * This can help limiting how the Camera is able to move in the scene.
  44448. */
  44449. lowerRotationOffsetLimit: Nullable<number>;
  44450. /**
  44451. * Maximum allowed angle to camera position relative to target object.
  44452. * This can help limiting how the Camera is able to move in the scene.
  44453. */
  44454. upperRotationOffsetLimit: Nullable<number>;
  44455. /**
  44456. * Define a height offset between the camera and the object it follows.
  44457. * It can help following an object from the top (like a car chaing a plane)
  44458. */
  44459. heightOffset: number;
  44460. /**
  44461. * Minimum allowed height of camera position relative to target object.
  44462. * This can help limiting how the Camera is able to move in the scene.
  44463. */
  44464. lowerHeightOffsetLimit: Nullable<number>;
  44465. /**
  44466. * Maximum allowed height of camera position relative to target object.
  44467. * This can help limiting how the Camera is able to move in the scene.
  44468. */
  44469. upperHeightOffsetLimit: Nullable<number>;
  44470. /**
  44471. * Define how fast the camera can accelerate to follow it s target.
  44472. */
  44473. cameraAcceleration: number;
  44474. /**
  44475. * Define the speed limit of the camera following an object.
  44476. */
  44477. maxCameraSpeed: number;
  44478. /**
  44479. * Define the target of the camera.
  44480. */
  44481. lockedTarget: Nullable<AbstractMesh>;
  44482. /**
  44483. * Defines the input associated with the camera.
  44484. */
  44485. inputs: FollowCameraInputsManager;
  44486. /**
  44487. * Instantiates the follow camera.
  44488. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44489. * @param name Define the name of the camera in the scene
  44490. * @param position Define the position of the camera
  44491. * @param scene Define the scene the camera belong to
  44492. * @param lockedTarget Define the target of the camera
  44493. */
  44494. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44495. private _follow;
  44496. /**
  44497. * Attached controls to the current camera.
  44498. * @param element Defines the element the controls should be listened from
  44499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44500. */
  44501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44502. /**
  44503. * Detach the current controls from the camera.
  44504. * The camera will stop reacting to inputs.
  44505. * @param element Defines the element to stop listening the inputs from
  44506. */
  44507. detachControl(element: HTMLElement): void;
  44508. /** @hidden */
  44509. _checkInputs(): void;
  44510. private _checkLimits;
  44511. /**
  44512. * Gets the camera class name.
  44513. * @returns the class name
  44514. */
  44515. getClassName(): string;
  44516. }
  44517. /**
  44518. * Arc Rotate version of the follow camera.
  44519. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44520. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44521. */
  44522. export class ArcFollowCamera extends TargetCamera {
  44523. /** The longitudinal angle of the camera */
  44524. alpha: number;
  44525. /** The latitudinal angle of the camera */
  44526. beta: number;
  44527. /** The radius of the camera from its target */
  44528. radius: number;
  44529. /** Define the camera target (the mesh it should follow) */
  44530. target: Nullable<AbstractMesh>;
  44531. private _cartesianCoordinates;
  44532. /**
  44533. * Instantiates a new ArcFollowCamera
  44534. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44535. * @param name Define the name of the camera
  44536. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44537. * @param beta Define the rotation angle of the camera around the elevation axis
  44538. * @param radius Define the radius of the camera from its target point
  44539. * @param target Define the target of the camera
  44540. * @param scene Define the scene the camera belongs to
  44541. */
  44542. constructor(name: string,
  44543. /** The longitudinal angle of the camera */
  44544. alpha: number,
  44545. /** The latitudinal angle of the camera */
  44546. beta: number,
  44547. /** The radius of the camera from its target */
  44548. radius: number,
  44549. /** Define the camera target (the mesh it should follow) */
  44550. target: Nullable<AbstractMesh>, scene: Scene);
  44551. private _follow;
  44552. /** @hidden */
  44553. _checkInputs(): void;
  44554. /**
  44555. * Returns the class name of the object.
  44556. * It is mostly used internally for serialization purposes.
  44557. */
  44558. getClassName(): string;
  44559. }
  44560. }
  44561. declare module BABYLON {
  44562. /**
  44563. * Manage the keyboard inputs to control the movement of a follow camera.
  44564. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44565. */
  44566. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44567. /**
  44568. * Defines the camera the input is attached to.
  44569. */
  44570. camera: FollowCamera;
  44571. /**
  44572. * Defines the list of key codes associated with the up action (increase heightOffset)
  44573. */
  44574. keysHeightOffsetIncr: number[];
  44575. /**
  44576. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44577. */
  44578. keysHeightOffsetDecr: number[];
  44579. /**
  44580. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44581. */
  44582. keysHeightOffsetModifierAlt: boolean;
  44583. /**
  44584. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44585. */
  44586. keysHeightOffsetModifierCtrl: boolean;
  44587. /**
  44588. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44589. */
  44590. keysHeightOffsetModifierShift: boolean;
  44591. /**
  44592. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44593. */
  44594. keysRotationOffsetIncr: number[];
  44595. /**
  44596. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44597. */
  44598. keysRotationOffsetDecr: number[];
  44599. /**
  44600. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44601. */
  44602. keysRotationOffsetModifierAlt: boolean;
  44603. /**
  44604. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44605. */
  44606. keysRotationOffsetModifierCtrl: boolean;
  44607. /**
  44608. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44609. */
  44610. keysRotationOffsetModifierShift: boolean;
  44611. /**
  44612. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44613. */
  44614. keysRadiusIncr: number[];
  44615. /**
  44616. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44617. */
  44618. keysRadiusDecr: number[];
  44619. /**
  44620. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44621. */
  44622. keysRadiusModifierAlt: boolean;
  44623. /**
  44624. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44625. */
  44626. keysRadiusModifierCtrl: boolean;
  44627. /**
  44628. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44629. */
  44630. keysRadiusModifierShift: boolean;
  44631. /**
  44632. * Defines the rate of change of heightOffset.
  44633. */
  44634. heightSensibility: number;
  44635. /**
  44636. * Defines the rate of change of rotationOffset.
  44637. */
  44638. rotationSensibility: number;
  44639. /**
  44640. * Defines the rate of change of radius.
  44641. */
  44642. radiusSensibility: number;
  44643. private _keys;
  44644. private _ctrlPressed;
  44645. private _altPressed;
  44646. private _shiftPressed;
  44647. private _onCanvasBlurObserver;
  44648. private _onKeyboardObserver;
  44649. private _engine;
  44650. private _scene;
  44651. /**
  44652. * Attach the input controls to a specific dom element to get the input from.
  44653. * @param element Defines the element the controls should be listened from
  44654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44655. */
  44656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44657. /**
  44658. * Detach the current controls from the specified dom element.
  44659. * @param element Defines the element to stop listening the inputs from
  44660. */
  44661. detachControl(element: Nullable<HTMLElement>): void;
  44662. /**
  44663. * Update the current camera state depending on the inputs that have been used this frame.
  44664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44665. */
  44666. checkInputs(): void;
  44667. /**
  44668. * Gets the class name of the current input.
  44669. * @returns the class name
  44670. */
  44671. getClassName(): string;
  44672. /**
  44673. * Get the friendly name associated with the input class.
  44674. * @returns the input friendly name
  44675. */
  44676. getSimpleName(): string;
  44677. /**
  44678. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44679. * allow modification of the heightOffset value.
  44680. */
  44681. private _modifierHeightOffset;
  44682. /**
  44683. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44684. * allow modification of the rotationOffset value.
  44685. */
  44686. private _modifierRotationOffset;
  44687. /**
  44688. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44689. * allow modification of the radius value.
  44690. */
  44691. private _modifierRadius;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. interface FreeCameraInputsManager {
  44696. /**
  44697. * @hidden
  44698. */
  44699. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44700. /**
  44701. * Add orientation input support to the input manager.
  44702. * @returns the current input manager
  44703. */
  44704. addDeviceOrientation(): FreeCameraInputsManager;
  44705. }
  44706. /**
  44707. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44708. * Screen rotation is taken into account.
  44709. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44710. */
  44711. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44712. private _camera;
  44713. private _screenOrientationAngle;
  44714. private _constantTranform;
  44715. private _screenQuaternion;
  44716. private _alpha;
  44717. private _beta;
  44718. private _gamma;
  44719. /**
  44720. * Can be used to detect if a device orientation sensor is available on a device
  44721. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44722. * @returns a promise that will resolve on orientation change
  44723. */
  44724. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44725. /**
  44726. * @hidden
  44727. */
  44728. _onDeviceOrientationChangedObservable: Observable<void>;
  44729. /**
  44730. * Instantiates a new input
  44731. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44732. */
  44733. constructor();
  44734. /**
  44735. * Define the camera controlled by the input.
  44736. */
  44737. get camera(): FreeCamera;
  44738. set camera(camera: FreeCamera);
  44739. /**
  44740. * Attach the input controls to a specific dom element to get the input from.
  44741. * @param element Defines the element the controls should be listened from
  44742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44743. */
  44744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44745. private _orientationChanged;
  44746. private _deviceOrientation;
  44747. /**
  44748. * Detach the current controls from the specified dom element.
  44749. * @param element Defines the element to stop listening the inputs from
  44750. */
  44751. detachControl(element: Nullable<HTMLElement>): void;
  44752. /**
  44753. * Update the current camera state depending on the inputs that have been used this frame.
  44754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44755. */
  44756. checkInputs(): void;
  44757. /**
  44758. * Gets the class name of the current intput.
  44759. * @returns the class name
  44760. */
  44761. getClassName(): string;
  44762. /**
  44763. * Get the friendly name associated with the input class.
  44764. * @returns the input friendly name
  44765. */
  44766. getSimpleName(): string;
  44767. }
  44768. }
  44769. declare module BABYLON {
  44770. /**
  44771. * Manage the gamepad inputs to control a free camera.
  44772. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44773. */
  44774. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44775. /**
  44776. * Define the camera the input is attached to.
  44777. */
  44778. camera: FreeCamera;
  44779. /**
  44780. * Define the Gamepad controlling the input
  44781. */
  44782. gamepad: Nullable<Gamepad>;
  44783. /**
  44784. * Defines the gamepad rotation sensiblity.
  44785. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44786. */
  44787. gamepadAngularSensibility: number;
  44788. /**
  44789. * Defines the gamepad move sensiblity.
  44790. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44791. */
  44792. gamepadMoveSensibility: number;
  44793. private _yAxisScale;
  44794. /**
  44795. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44796. */
  44797. get invertYAxis(): boolean;
  44798. set invertYAxis(value: boolean);
  44799. private _onGamepadConnectedObserver;
  44800. private _onGamepadDisconnectedObserver;
  44801. private _cameraTransform;
  44802. private _deltaTransform;
  44803. private _vector3;
  44804. private _vector2;
  44805. /**
  44806. * Attach the input controls to a specific dom element to get the input from.
  44807. * @param element Defines the element the controls should be listened from
  44808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44809. */
  44810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44811. /**
  44812. * Detach the current controls from the specified dom element.
  44813. * @param element Defines the element to stop listening the inputs from
  44814. */
  44815. detachControl(element: Nullable<HTMLElement>): void;
  44816. /**
  44817. * Update the current camera state depending on the inputs that have been used this frame.
  44818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44819. */
  44820. checkInputs(): void;
  44821. /**
  44822. * Gets the class name of the current intput.
  44823. * @returns the class name
  44824. */
  44825. getClassName(): string;
  44826. /**
  44827. * Get the friendly name associated with the input class.
  44828. * @returns the input friendly name
  44829. */
  44830. getSimpleName(): string;
  44831. }
  44832. }
  44833. declare module BABYLON {
  44834. /**
  44835. * Defines the potential axis of a Joystick
  44836. */
  44837. export enum JoystickAxis {
  44838. /** X axis */
  44839. X = 0,
  44840. /** Y axis */
  44841. Y = 1,
  44842. /** Z axis */
  44843. Z = 2
  44844. }
  44845. /**
  44846. * Represents the different customization options available
  44847. * for VirtualJoystick
  44848. */
  44849. interface VirtualJoystickCustomizations {
  44850. /**
  44851. * Size of the joystick's puck
  44852. */
  44853. puckSize: number;
  44854. /**
  44855. * Size of the joystick's container
  44856. */
  44857. containerSize: number;
  44858. /**
  44859. * Color of the joystick && puck
  44860. */
  44861. color: string;
  44862. /**
  44863. * Image URL for the joystick's puck
  44864. */
  44865. puckImage?: string;
  44866. /**
  44867. * Image URL for the joystick's container
  44868. */
  44869. containerImage?: string;
  44870. /**
  44871. * Defines the unmoving position of the joystick container
  44872. */
  44873. position?: {
  44874. x: number;
  44875. y: number;
  44876. };
  44877. /**
  44878. * Defines whether or not the joystick container is always visible
  44879. */
  44880. alwaysVisible: boolean;
  44881. /**
  44882. * Defines whether or not to limit the movement of the puck to the joystick's container
  44883. */
  44884. limitToContainer: boolean;
  44885. }
  44886. /**
  44887. * Class used to define virtual joystick (used in touch mode)
  44888. */
  44889. export class VirtualJoystick {
  44890. /**
  44891. * Gets or sets a boolean indicating that left and right values must be inverted
  44892. */
  44893. reverseLeftRight: boolean;
  44894. /**
  44895. * Gets or sets a boolean indicating that up and down values must be inverted
  44896. */
  44897. reverseUpDown: boolean;
  44898. /**
  44899. * Gets the offset value for the position (ie. the change of the position value)
  44900. */
  44901. deltaPosition: Vector3;
  44902. /**
  44903. * Gets a boolean indicating if the virtual joystick was pressed
  44904. */
  44905. pressed: boolean;
  44906. /**
  44907. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44908. */
  44909. static Canvas: Nullable<HTMLCanvasElement>;
  44910. /**
  44911. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44912. */
  44913. limitToContainer: boolean;
  44914. private static _globalJoystickIndex;
  44915. private static _alwaysVisibleSticks;
  44916. private static vjCanvasContext;
  44917. private static vjCanvasWidth;
  44918. private static vjCanvasHeight;
  44919. private static halfWidth;
  44920. private static _GetDefaultOptions;
  44921. private _action;
  44922. private _axisTargetedByLeftAndRight;
  44923. private _axisTargetedByUpAndDown;
  44924. private _joystickSensibility;
  44925. private _inversedSensibility;
  44926. private _joystickPointerID;
  44927. private _joystickColor;
  44928. private _joystickPointerPos;
  44929. private _joystickPreviousPointerPos;
  44930. private _joystickPointerStartPos;
  44931. private _deltaJoystickVector;
  44932. private _leftJoystick;
  44933. private _touches;
  44934. private _joystickPosition;
  44935. private _alwaysVisible;
  44936. private _puckImage;
  44937. private _containerImage;
  44938. private _joystickPuckSize;
  44939. private _joystickContainerSize;
  44940. private _clearPuckSize;
  44941. private _clearContainerSize;
  44942. private _clearPuckSizeOffset;
  44943. private _clearContainerSizeOffset;
  44944. private _onPointerDownHandlerRef;
  44945. private _onPointerMoveHandlerRef;
  44946. private _onPointerUpHandlerRef;
  44947. private _onResize;
  44948. /**
  44949. * Creates a new virtual joystick
  44950. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44951. * @param customizations Defines the options we want to customize the VirtualJoystick
  44952. */
  44953. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44954. /**
  44955. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44956. * @param newJoystickSensibility defines the new sensibility
  44957. */
  44958. setJoystickSensibility(newJoystickSensibility: number): void;
  44959. private _onPointerDown;
  44960. private _onPointerMove;
  44961. private _onPointerUp;
  44962. /**
  44963. * Change the color of the virtual joystick
  44964. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44965. */
  44966. setJoystickColor(newColor: string): void;
  44967. /**
  44968. * Size of the joystick's container
  44969. */
  44970. set containerSize(newSize: number);
  44971. get containerSize(): number;
  44972. /**
  44973. * Size of the joystick's puck
  44974. */
  44975. set puckSize(newSize: number);
  44976. get puckSize(): number;
  44977. /**
  44978. * Clears the set position of the joystick
  44979. */
  44980. clearPosition(): void;
  44981. /**
  44982. * Defines whether or not the joystick container is always visible
  44983. */
  44984. set alwaysVisible(value: boolean);
  44985. get alwaysVisible(): boolean;
  44986. /**
  44987. * Sets the constant position of the Joystick container
  44988. * @param x X axis coordinate
  44989. * @param y Y axis coordinate
  44990. */
  44991. setPosition(x: number, y: number): void;
  44992. /**
  44993. * Defines a callback to call when the joystick is touched
  44994. * @param action defines the callback
  44995. */
  44996. setActionOnTouch(action: () => any): void;
  44997. /**
  44998. * Defines which axis you'd like to control for left & right
  44999. * @param axis defines the axis to use
  45000. */
  45001. setAxisForLeftRight(axis: JoystickAxis): void;
  45002. /**
  45003. * Defines which axis you'd like to control for up & down
  45004. * @param axis defines the axis to use
  45005. */
  45006. setAxisForUpDown(axis: JoystickAxis): void;
  45007. /**
  45008. * Clears the canvas from the previous puck / container draw
  45009. */
  45010. private _clearPreviousDraw;
  45011. /**
  45012. * Loads `urlPath` to be used for the container's image
  45013. * @param urlPath defines the urlPath of an image to use
  45014. */
  45015. setContainerImage(urlPath: string): void;
  45016. /**
  45017. * Loads `urlPath` to be used for the puck's image
  45018. * @param urlPath defines the urlPath of an image to use
  45019. */
  45020. setPuckImage(urlPath: string): void;
  45021. /**
  45022. * Draws the Virtual Joystick's container
  45023. */
  45024. private _drawContainer;
  45025. /**
  45026. * Draws the Virtual Joystick's puck
  45027. */
  45028. private _drawPuck;
  45029. private _drawVirtualJoystick;
  45030. /**
  45031. * Release internal HTML canvas
  45032. */
  45033. releaseCanvas(): void;
  45034. }
  45035. }
  45036. declare module BABYLON {
  45037. interface FreeCameraInputsManager {
  45038. /**
  45039. * Add virtual joystick input support to the input manager.
  45040. * @returns the current input manager
  45041. */
  45042. addVirtualJoystick(): FreeCameraInputsManager;
  45043. }
  45044. /**
  45045. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45046. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45047. */
  45048. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45049. /**
  45050. * Defines the camera the input is attached to.
  45051. */
  45052. camera: FreeCamera;
  45053. private _leftjoystick;
  45054. private _rightjoystick;
  45055. /**
  45056. * Gets the left stick of the virtual joystick.
  45057. * @returns The virtual Joystick
  45058. */
  45059. getLeftJoystick(): VirtualJoystick;
  45060. /**
  45061. * Gets the right stick of the virtual joystick.
  45062. * @returns The virtual Joystick
  45063. */
  45064. getRightJoystick(): VirtualJoystick;
  45065. /**
  45066. * Update the current camera state depending on the inputs that have been used this frame.
  45067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45068. */
  45069. checkInputs(): void;
  45070. /**
  45071. * Attach the input controls to a specific dom element to get the input from.
  45072. * @param element Defines the element the controls should be listened from
  45073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45074. */
  45075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45076. /**
  45077. * Detach the current controls from the specified dom element.
  45078. * @param element Defines the element to stop listening the inputs from
  45079. */
  45080. detachControl(element: Nullable<HTMLElement>): void;
  45081. /**
  45082. * Gets the class name of the current intput.
  45083. * @returns the class name
  45084. */
  45085. getClassName(): string;
  45086. /**
  45087. * Get the friendly name associated with the input class.
  45088. * @returns the input friendly name
  45089. */
  45090. getSimpleName(): string;
  45091. }
  45092. }
  45093. declare module BABYLON {
  45094. /**
  45095. * This represents a FPS type of camera controlled by touch.
  45096. * This is like a universal camera minus the Gamepad controls.
  45097. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45098. */
  45099. export class TouchCamera extends FreeCamera {
  45100. /**
  45101. * Defines the touch sensibility for rotation.
  45102. * The higher the faster.
  45103. */
  45104. get touchAngularSensibility(): number;
  45105. set touchAngularSensibility(value: number);
  45106. /**
  45107. * Defines the touch sensibility for move.
  45108. * The higher the faster.
  45109. */
  45110. get touchMoveSensibility(): number;
  45111. set touchMoveSensibility(value: number);
  45112. /**
  45113. * Instantiates a new touch camera.
  45114. * This represents a FPS type of camera controlled by touch.
  45115. * This is like a universal camera minus the Gamepad controls.
  45116. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45117. * @param name Define the name of the camera in the scene
  45118. * @param position Define the start position of the camera in the scene
  45119. * @param scene Define the scene the camera belongs to
  45120. */
  45121. constructor(name: string, position: Vector3, scene: Scene);
  45122. /**
  45123. * Gets the current object class name.
  45124. * @return the class name
  45125. */
  45126. getClassName(): string;
  45127. /** @hidden */
  45128. _setupInputs(): void;
  45129. }
  45130. }
  45131. declare module BABYLON {
  45132. /**
  45133. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45134. * being tilted forward or back and left or right.
  45135. */
  45136. export class DeviceOrientationCamera extends FreeCamera {
  45137. private _initialQuaternion;
  45138. private _quaternionCache;
  45139. private _tmpDragQuaternion;
  45140. private _disablePointerInputWhenUsingDeviceOrientation;
  45141. /**
  45142. * Creates a new device orientation camera
  45143. * @param name The name of the camera
  45144. * @param position The start position camera
  45145. * @param scene The scene the camera belongs to
  45146. */
  45147. constructor(name: string, position: Vector3, scene: Scene);
  45148. /**
  45149. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45150. */
  45151. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45152. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45153. private _dragFactor;
  45154. /**
  45155. * Enabled turning on the y axis when the orientation sensor is active
  45156. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45157. */
  45158. enableHorizontalDragging(dragFactor?: number): void;
  45159. /**
  45160. * Gets the current instance class name ("DeviceOrientationCamera").
  45161. * This helps avoiding instanceof at run time.
  45162. * @returns the class name
  45163. */
  45164. getClassName(): string;
  45165. /**
  45166. * @hidden
  45167. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45168. */
  45169. _checkInputs(): void;
  45170. /**
  45171. * Reset the camera to its default orientation on the specified axis only.
  45172. * @param axis The axis to reset
  45173. */
  45174. resetToCurrentRotation(axis?: Axis): void;
  45175. }
  45176. }
  45177. declare module BABYLON {
  45178. /**
  45179. * Defines supported buttons for XBox360 compatible gamepads
  45180. */
  45181. export enum Xbox360Button {
  45182. /** A */
  45183. A = 0,
  45184. /** B */
  45185. B = 1,
  45186. /** X */
  45187. X = 2,
  45188. /** Y */
  45189. Y = 3,
  45190. /** Left button */
  45191. LB = 4,
  45192. /** Right button */
  45193. RB = 5,
  45194. /** Back */
  45195. Back = 8,
  45196. /** Start */
  45197. Start = 9,
  45198. /** Left stick */
  45199. LeftStick = 10,
  45200. /** Right stick */
  45201. RightStick = 11
  45202. }
  45203. /** Defines values for XBox360 DPad */
  45204. export enum Xbox360Dpad {
  45205. /** Up */
  45206. Up = 12,
  45207. /** Down */
  45208. Down = 13,
  45209. /** Left */
  45210. Left = 14,
  45211. /** Right */
  45212. Right = 15
  45213. }
  45214. /**
  45215. * Defines a XBox360 gamepad
  45216. */
  45217. export class Xbox360Pad extends Gamepad {
  45218. private _leftTrigger;
  45219. private _rightTrigger;
  45220. private _onlefttriggerchanged;
  45221. private _onrighttriggerchanged;
  45222. private _onbuttondown;
  45223. private _onbuttonup;
  45224. private _ondpaddown;
  45225. private _ondpadup;
  45226. /** Observable raised when a button is pressed */
  45227. onButtonDownObservable: Observable<Xbox360Button>;
  45228. /** Observable raised when a button is released */
  45229. onButtonUpObservable: Observable<Xbox360Button>;
  45230. /** Observable raised when a pad is pressed */
  45231. onPadDownObservable: Observable<Xbox360Dpad>;
  45232. /** Observable raised when a pad is released */
  45233. onPadUpObservable: Observable<Xbox360Dpad>;
  45234. private _buttonA;
  45235. private _buttonB;
  45236. private _buttonX;
  45237. private _buttonY;
  45238. private _buttonBack;
  45239. private _buttonStart;
  45240. private _buttonLB;
  45241. private _buttonRB;
  45242. private _buttonLeftStick;
  45243. private _buttonRightStick;
  45244. private _dPadUp;
  45245. private _dPadDown;
  45246. private _dPadLeft;
  45247. private _dPadRight;
  45248. private _isXboxOnePad;
  45249. /**
  45250. * Creates a new XBox360 gamepad object
  45251. * @param id defines the id of this gamepad
  45252. * @param index defines its index
  45253. * @param gamepad defines the internal HTML gamepad object
  45254. * @param xboxOne defines if it is a XBox One gamepad
  45255. */
  45256. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45257. /**
  45258. * Defines the callback to call when left trigger is pressed
  45259. * @param callback defines the callback to use
  45260. */
  45261. onlefttriggerchanged(callback: (value: number) => void): void;
  45262. /**
  45263. * Defines the callback to call when right trigger is pressed
  45264. * @param callback defines the callback to use
  45265. */
  45266. onrighttriggerchanged(callback: (value: number) => void): void;
  45267. /**
  45268. * Gets the left trigger value
  45269. */
  45270. get leftTrigger(): number;
  45271. /**
  45272. * Sets the left trigger value
  45273. */
  45274. set leftTrigger(newValue: number);
  45275. /**
  45276. * Gets the right trigger value
  45277. */
  45278. get rightTrigger(): number;
  45279. /**
  45280. * Sets the right trigger value
  45281. */
  45282. set rightTrigger(newValue: number);
  45283. /**
  45284. * Defines the callback to call when a button is pressed
  45285. * @param callback defines the callback to use
  45286. */
  45287. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45288. /**
  45289. * Defines the callback to call when a button is released
  45290. * @param callback defines the callback to use
  45291. */
  45292. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45293. /**
  45294. * Defines the callback to call when a pad is pressed
  45295. * @param callback defines the callback to use
  45296. */
  45297. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45298. /**
  45299. * Defines the callback to call when a pad is released
  45300. * @param callback defines the callback to use
  45301. */
  45302. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45303. private _setButtonValue;
  45304. private _setDPadValue;
  45305. /**
  45306. * Gets the value of the `A` button
  45307. */
  45308. get buttonA(): number;
  45309. /**
  45310. * Sets the value of the `A` button
  45311. */
  45312. set buttonA(value: number);
  45313. /**
  45314. * Gets the value of the `B` button
  45315. */
  45316. get buttonB(): number;
  45317. /**
  45318. * Sets the value of the `B` button
  45319. */
  45320. set buttonB(value: number);
  45321. /**
  45322. * Gets the value of the `X` button
  45323. */
  45324. get buttonX(): number;
  45325. /**
  45326. * Sets the value of the `X` button
  45327. */
  45328. set buttonX(value: number);
  45329. /**
  45330. * Gets the value of the `Y` button
  45331. */
  45332. get buttonY(): number;
  45333. /**
  45334. * Sets the value of the `Y` button
  45335. */
  45336. set buttonY(value: number);
  45337. /**
  45338. * Gets the value of the `Start` button
  45339. */
  45340. get buttonStart(): number;
  45341. /**
  45342. * Sets the value of the `Start` button
  45343. */
  45344. set buttonStart(value: number);
  45345. /**
  45346. * Gets the value of the `Back` button
  45347. */
  45348. get buttonBack(): number;
  45349. /**
  45350. * Sets the value of the `Back` button
  45351. */
  45352. set buttonBack(value: number);
  45353. /**
  45354. * Gets the value of the `Left` button
  45355. */
  45356. get buttonLB(): number;
  45357. /**
  45358. * Sets the value of the `Left` button
  45359. */
  45360. set buttonLB(value: number);
  45361. /**
  45362. * Gets the value of the `Right` button
  45363. */
  45364. get buttonRB(): number;
  45365. /**
  45366. * Sets the value of the `Right` button
  45367. */
  45368. set buttonRB(value: number);
  45369. /**
  45370. * Gets the value of the Left joystick
  45371. */
  45372. get buttonLeftStick(): number;
  45373. /**
  45374. * Sets the value of the Left joystick
  45375. */
  45376. set buttonLeftStick(value: number);
  45377. /**
  45378. * Gets the value of the Right joystick
  45379. */
  45380. get buttonRightStick(): number;
  45381. /**
  45382. * Sets the value of the Right joystick
  45383. */
  45384. set buttonRightStick(value: number);
  45385. /**
  45386. * Gets the value of D-pad up
  45387. */
  45388. get dPadUp(): number;
  45389. /**
  45390. * Sets the value of D-pad up
  45391. */
  45392. set dPadUp(value: number);
  45393. /**
  45394. * Gets the value of D-pad down
  45395. */
  45396. get dPadDown(): number;
  45397. /**
  45398. * Sets the value of D-pad down
  45399. */
  45400. set dPadDown(value: number);
  45401. /**
  45402. * Gets the value of D-pad left
  45403. */
  45404. get dPadLeft(): number;
  45405. /**
  45406. * Sets the value of D-pad left
  45407. */
  45408. set dPadLeft(value: number);
  45409. /**
  45410. * Gets the value of D-pad right
  45411. */
  45412. get dPadRight(): number;
  45413. /**
  45414. * Sets the value of D-pad right
  45415. */
  45416. set dPadRight(value: number);
  45417. /**
  45418. * Force the gamepad to synchronize with device values
  45419. */
  45420. update(): void;
  45421. /**
  45422. * Disposes the gamepad
  45423. */
  45424. dispose(): void;
  45425. }
  45426. }
  45427. declare module BABYLON {
  45428. /**
  45429. * Defines supported buttons for DualShock compatible gamepads
  45430. */
  45431. export enum DualShockButton {
  45432. /** Cross */
  45433. Cross = 0,
  45434. /** Circle */
  45435. Circle = 1,
  45436. /** Square */
  45437. Square = 2,
  45438. /** Triangle */
  45439. Triangle = 3,
  45440. /** L1 */
  45441. L1 = 4,
  45442. /** R1 */
  45443. R1 = 5,
  45444. /** Share */
  45445. Share = 8,
  45446. /** Options */
  45447. Options = 9,
  45448. /** Left stick */
  45449. LeftStick = 10,
  45450. /** Right stick */
  45451. RightStick = 11
  45452. }
  45453. /** Defines values for DualShock DPad */
  45454. export enum DualShockDpad {
  45455. /** Up */
  45456. Up = 12,
  45457. /** Down */
  45458. Down = 13,
  45459. /** Left */
  45460. Left = 14,
  45461. /** Right */
  45462. Right = 15
  45463. }
  45464. /**
  45465. * Defines a DualShock gamepad
  45466. */
  45467. export class DualShockPad extends Gamepad {
  45468. private _leftTrigger;
  45469. private _rightTrigger;
  45470. private _onlefttriggerchanged;
  45471. private _onrighttriggerchanged;
  45472. private _onbuttondown;
  45473. private _onbuttonup;
  45474. private _ondpaddown;
  45475. private _ondpadup;
  45476. /** Observable raised when a button is pressed */
  45477. onButtonDownObservable: Observable<DualShockButton>;
  45478. /** Observable raised when a button is released */
  45479. onButtonUpObservable: Observable<DualShockButton>;
  45480. /** Observable raised when a pad is pressed */
  45481. onPadDownObservable: Observable<DualShockDpad>;
  45482. /** Observable raised when a pad is released */
  45483. onPadUpObservable: Observable<DualShockDpad>;
  45484. private _buttonCross;
  45485. private _buttonCircle;
  45486. private _buttonSquare;
  45487. private _buttonTriangle;
  45488. private _buttonShare;
  45489. private _buttonOptions;
  45490. private _buttonL1;
  45491. private _buttonR1;
  45492. private _buttonLeftStick;
  45493. private _buttonRightStick;
  45494. private _dPadUp;
  45495. private _dPadDown;
  45496. private _dPadLeft;
  45497. private _dPadRight;
  45498. /**
  45499. * Creates a new DualShock gamepad object
  45500. * @param id defines the id of this gamepad
  45501. * @param index defines its index
  45502. * @param gamepad defines the internal HTML gamepad object
  45503. */
  45504. constructor(id: string, index: number, gamepad: any);
  45505. /**
  45506. * Defines the callback to call when left trigger is pressed
  45507. * @param callback defines the callback to use
  45508. */
  45509. onlefttriggerchanged(callback: (value: number) => void): void;
  45510. /**
  45511. * Defines the callback to call when right trigger is pressed
  45512. * @param callback defines the callback to use
  45513. */
  45514. onrighttriggerchanged(callback: (value: number) => void): void;
  45515. /**
  45516. * Gets the left trigger value
  45517. */
  45518. get leftTrigger(): number;
  45519. /**
  45520. * Sets the left trigger value
  45521. */
  45522. set leftTrigger(newValue: number);
  45523. /**
  45524. * Gets the right trigger value
  45525. */
  45526. get rightTrigger(): number;
  45527. /**
  45528. * Sets the right trigger value
  45529. */
  45530. set rightTrigger(newValue: number);
  45531. /**
  45532. * Defines the callback to call when a button is pressed
  45533. * @param callback defines the callback to use
  45534. */
  45535. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45536. /**
  45537. * Defines the callback to call when a button is released
  45538. * @param callback defines the callback to use
  45539. */
  45540. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45541. /**
  45542. * Defines the callback to call when a pad is pressed
  45543. * @param callback defines the callback to use
  45544. */
  45545. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45546. /**
  45547. * Defines the callback to call when a pad is released
  45548. * @param callback defines the callback to use
  45549. */
  45550. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45551. private _setButtonValue;
  45552. private _setDPadValue;
  45553. /**
  45554. * Gets the value of the `Cross` button
  45555. */
  45556. get buttonCross(): number;
  45557. /**
  45558. * Sets the value of the `Cross` button
  45559. */
  45560. set buttonCross(value: number);
  45561. /**
  45562. * Gets the value of the `Circle` button
  45563. */
  45564. get buttonCircle(): number;
  45565. /**
  45566. * Sets the value of the `Circle` button
  45567. */
  45568. set buttonCircle(value: number);
  45569. /**
  45570. * Gets the value of the `Square` button
  45571. */
  45572. get buttonSquare(): number;
  45573. /**
  45574. * Sets the value of the `Square` button
  45575. */
  45576. set buttonSquare(value: number);
  45577. /**
  45578. * Gets the value of the `Triangle` button
  45579. */
  45580. get buttonTriangle(): number;
  45581. /**
  45582. * Sets the value of the `Triangle` button
  45583. */
  45584. set buttonTriangle(value: number);
  45585. /**
  45586. * Gets the value of the `Options` button
  45587. */
  45588. get buttonOptions(): number;
  45589. /**
  45590. * Sets the value of the `Options` button
  45591. */
  45592. set buttonOptions(value: number);
  45593. /**
  45594. * Gets the value of the `Share` button
  45595. */
  45596. get buttonShare(): number;
  45597. /**
  45598. * Sets the value of the `Share` button
  45599. */
  45600. set buttonShare(value: number);
  45601. /**
  45602. * Gets the value of the `L1` button
  45603. */
  45604. get buttonL1(): number;
  45605. /**
  45606. * Sets the value of the `L1` button
  45607. */
  45608. set buttonL1(value: number);
  45609. /**
  45610. * Gets the value of the `R1` button
  45611. */
  45612. get buttonR1(): number;
  45613. /**
  45614. * Sets the value of the `R1` button
  45615. */
  45616. set buttonR1(value: number);
  45617. /**
  45618. * Gets the value of the Left joystick
  45619. */
  45620. get buttonLeftStick(): number;
  45621. /**
  45622. * Sets the value of the Left joystick
  45623. */
  45624. set buttonLeftStick(value: number);
  45625. /**
  45626. * Gets the value of the Right joystick
  45627. */
  45628. get buttonRightStick(): number;
  45629. /**
  45630. * Sets the value of the Right joystick
  45631. */
  45632. set buttonRightStick(value: number);
  45633. /**
  45634. * Gets the value of D-pad up
  45635. */
  45636. get dPadUp(): number;
  45637. /**
  45638. * Sets the value of D-pad up
  45639. */
  45640. set dPadUp(value: number);
  45641. /**
  45642. * Gets the value of D-pad down
  45643. */
  45644. get dPadDown(): number;
  45645. /**
  45646. * Sets the value of D-pad down
  45647. */
  45648. set dPadDown(value: number);
  45649. /**
  45650. * Gets the value of D-pad left
  45651. */
  45652. get dPadLeft(): number;
  45653. /**
  45654. * Sets the value of D-pad left
  45655. */
  45656. set dPadLeft(value: number);
  45657. /**
  45658. * Gets the value of D-pad right
  45659. */
  45660. get dPadRight(): number;
  45661. /**
  45662. * Sets the value of D-pad right
  45663. */
  45664. set dPadRight(value: number);
  45665. /**
  45666. * Force the gamepad to synchronize with device values
  45667. */
  45668. update(): void;
  45669. /**
  45670. * Disposes the gamepad
  45671. */
  45672. dispose(): void;
  45673. }
  45674. }
  45675. declare module BABYLON {
  45676. /**
  45677. * Manager for handling gamepads
  45678. */
  45679. export class GamepadManager {
  45680. private _scene?;
  45681. private _babylonGamepads;
  45682. private _oneGamepadConnected;
  45683. /** @hidden */
  45684. _isMonitoring: boolean;
  45685. private _gamepadEventSupported;
  45686. private _gamepadSupport?;
  45687. /**
  45688. * observable to be triggered when the gamepad controller has been connected
  45689. */
  45690. onGamepadConnectedObservable: Observable<Gamepad>;
  45691. /**
  45692. * observable to be triggered when the gamepad controller has been disconnected
  45693. */
  45694. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45695. private _onGamepadConnectedEvent;
  45696. private _onGamepadDisconnectedEvent;
  45697. /**
  45698. * Initializes the gamepad manager
  45699. * @param _scene BabylonJS scene
  45700. */
  45701. constructor(_scene?: Scene | undefined);
  45702. /**
  45703. * The gamepads in the game pad manager
  45704. */
  45705. get gamepads(): Gamepad[];
  45706. /**
  45707. * Get the gamepad controllers based on type
  45708. * @param type The type of gamepad controller
  45709. * @returns Nullable gamepad
  45710. */
  45711. getGamepadByType(type?: number): Nullable<Gamepad>;
  45712. /**
  45713. * Disposes the gamepad manager
  45714. */
  45715. dispose(): void;
  45716. private _addNewGamepad;
  45717. private _startMonitoringGamepads;
  45718. private _stopMonitoringGamepads;
  45719. /** @hidden */
  45720. _checkGamepadsStatus(): void;
  45721. private _updateGamepadObjects;
  45722. }
  45723. }
  45724. declare module BABYLON {
  45725. interface Scene {
  45726. /** @hidden */
  45727. _gamepadManager: Nullable<GamepadManager>;
  45728. /**
  45729. * Gets the gamepad manager associated with the scene
  45730. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45731. */
  45732. gamepadManager: GamepadManager;
  45733. }
  45734. /**
  45735. * Interface representing a free camera inputs manager
  45736. */
  45737. interface FreeCameraInputsManager {
  45738. /**
  45739. * Adds gamepad input support to the FreeCameraInputsManager.
  45740. * @returns the FreeCameraInputsManager
  45741. */
  45742. addGamepad(): FreeCameraInputsManager;
  45743. }
  45744. /**
  45745. * Interface representing an arc rotate camera inputs manager
  45746. */
  45747. interface ArcRotateCameraInputsManager {
  45748. /**
  45749. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45750. * @returns the camera inputs manager
  45751. */
  45752. addGamepad(): ArcRotateCameraInputsManager;
  45753. }
  45754. /**
  45755. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45756. */
  45757. export class GamepadSystemSceneComponent implements ISceneComponent {
  45758. /**
  45759. * The component name helpfull to identify the component in the list of scene components.
  45760. */
  45761. readonly name: string;
  45762. /**
  45763. * The scene the component belongs to.
  45764. */
  45765. scene: Scene;
  45766. /**
  45767. * Creates a new instance of the component for the given scene
  45768. * @param scene Defines the scene to register the component in
  45769. */
  45770. constructor(scene: Scene);
  45771. /**
  45772. * Registers the component in a given scene
  45773. */
  45774. register(): void;
  45775. /**
  45776. * Rebuilds the elements related to this component in case of
  45777. * context lost for instance.
  45778. */
  45779. rebuild(): void;
  45780. /**
  45781. * Disposes the component and the associated ressources
  45782. */
  45783. dispose(): void;
  45784. private _beforeCameraUpdate;
  45785. }
  45786. }
  45787. declare module BABYLON {
  45788. /**
  45789. * 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,
  45790. * which still works and will still be found in many Playgrounds.
  45791. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45792. */
  45793. export class UniversalCamera extends TouchCamera {
  45794. /**
  45795. * Defines the gamepad rotation sensiblity.
  45796. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45797. */
  45798. get gamepadAngularSensibility(): number;
  45799. set gamepadAngularSensibility(value: number);
  45800. /**
  45801. * Defines the gamepad move sensiblity.
  45802. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45803. */
  45804. get gamepadMoveSensibility(): number;
  45805. set gamepadMoveSensibility(value: number);
  45806. /**
  45807. * 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,
  45808. * which still works and will still be found in many Playgrounds.
  45809. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45810. * @param name Define the name of the camera in the scene
  45811. * @param position Define the start position of the camera in the scene
  45812. * @param scene Define the scene the camera belongs to
  45813. */
  45814. constructor(name: string, position: Vector3, scene: Scene);
  45815. /**
  45816. * Gets the current object class name.
  45817. * @return the class name
  45818. */
  45819. getClassName(): string;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * This represents a FPS type of camera. This is only here for back compat purpose.
  45825. * Please use the UniversalCamera instead as both are identical.
  45826. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45827. */
  45828. export class GamepadCamera extends UniversalCamera {
  45829. /**
  45830. * Instantiates a new Gamepad Camera
  45831. * This represents a FPS type of camera. This is only here for back compat purpose.
  45832. * Please use the UniversalCamera instead as both are identical.
  45833. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45834. * @param name Define the name of the camera in the scene
  45835. * @param position Define the start position of the camera in the scene
  45836. * @param scene Define the scene the camera belongs to
  45837. */
  45838. constructor(name: string, position: Vector3, scene: Scene);
  45839. /**
  45840. * Gets the current object class name.
  45841. * @return the class name
  45842. */
  45843. getClassName(): string;
  45844. }
  45845. }
  45846. declare module BABYLON {
  45847. /** @hidden */
  45848. export var passPixelShader: {
  45849. name: string;
  45850. shader: string;
  45851. };
  45852. }
  45853. declare module BABYLON {
  45854. /** @hidden */
  45855. export var passCubePixelShader: {
  45856. name: string;
  45857. shader: string;
  45858. };
  45859. }
  45860. declare module BABYLON {
  45861. /**
  45862. * PassPostProcess which produces an output the same as it's input
  45863. */
  45864. export class PassPostProcess extends PostProcess {
  45865. /**
  45866. * Creates the PassPostProcess
  45867. * @param name The name of the effect.
  45868. * @param options The required width/height ratio to downsize to before computing the render pass.
  45869. * @param camera The camera to apply the render pass to.
  45870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45871. * @param engine The engine which the post process will be applied. (default: current engine)
  45872. * @param reusable If the post process can be reused on the same frame. (default: false)
  45873. * @param textureType The type of texture to be used when performing the post processing.
  45874. * @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)
  45875. */
  45876. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45877. }
  45878. /**
  45879. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45880. */
  45881. export class PassCubePostProcess extends PostProcess {
  45882. private _face;
  45883. /**
  45884. * Gets or sets the cube face to display.
  45885. * * 0 is +X
  45886. * * 1 is -X
  45887. * * 2 is +Y
  45888. * * 3 is -Y
  45889. * * 4 is +Z
  45890. * * 5 is -Z
  45891. */
  45892. get face(): number;
  45893. set face(value: number);
  45894. /**
  45895. * Creates the PassCubePostProcess
  45896. * @param name The name of the effect.
  45897. * @param options The required width/height ratio to downsize to before computing the render pass.
  45898. * @param camera The camera to apply the render pass to.
  45899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45900. * @param engine The engine which the post process will be applied. (default: current engine)
  45901. * @param reusable If the post process can be reused on the same frame. (default: false)
  45902. * @param textureType The type of texture to be used when performing the post processing.
  45903. * @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)
  45904. */
  45905. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45906. }
  45907. }
  45908. declare module BABYLON {
  45909. /** @hidden */
  45910. export var anaglyphPixelShader: {
  45911. name: string;
  45912. shader: string;
  45913. };
  45914. }
  45915. declare module BABYLON {
  45916. /**
  45917. * Postprocess used to generate anaglyphic rendering
  45918. */
  45919. export class AnaglyphPostProcess extends PostProcess {
  45920. private _passedProcess;
  45921. /**
  45922. * Creates a new AnaglyphPostProcess
  45923. * @param name defines postprocess name
  45924. * @param options defines creation options or target ratio scale
  45925. * @param rigCameras defines cameras using this postprocess
  45926. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45927. * @param engine defines hosting engine
  45928. * @param reusable defines if the postprocess will be reused multiple times per frame
  45929. */
  45930. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45931. }
  45932. }
  45933. declare module BABYLON {
  45934. /**
  45935. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45936. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45937. */
  45938. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45939. /**
  45940. * Creates a new AnaglyphArcRotateCamera
  45941. * @param name defines camera name
  45942. * @param alpha defines alpha angle (in radians)
  45943. * @param beta defines beta angle (in radians)
  45944. * @param radius defines radius
  45945. * @param target defines camera target
  45946. * @param interaxialDistance defines distance between each color axis
  45947. * @param scene defines the hosting scene
  45948. */
  45949. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45950. /**
  45951. * Gets camera class name
  45952. * @returns AnaglyphArcRotateCamera
  45953. */
  45954. getClassName(): string;
  45955. }
  45956. }
  45957. declare module BABYLON {
  45958. /**
  45959. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45960. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45961. */
  45962. export class AnaglyphFreeCamera extends FreeCamera {
  45963. /**
  45964. * Creates a new AnaglyphFreeCamera
  45965. * @param name defines camera name
  45966. * @param position defines initial position
  45967. * @param interaxialDistance defines distance between each color axis
  45968. * @param scene defines the hosting scene
  45969. */
  45970. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45971. /**
  45972. * Gets camera class name
  45973. * @returns AnaglyphFreeCamera
  45974. */
  45975. getClassName(): string;
  45976. }
  45977. }
  45978. declare module BABYLON {
  45979. /**
  45980. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45982. */
  45983. export class AnaglyphGamepadCamera extends GamepadCamera {
  45984. /**
  45985. * Creates a new AnaglyphGamepadCamera
  45986. * @param name defines camera name
  45987. * @param position defines initial position
  45988. * @param interaxialDistance defines distance between each color axis
  45989. * @param scene defines the hosting scene
  45990. */
  45991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45992. /**
  45993. * Gets camera class name
  45994. * @returns AnaglyphGamepadCamera
  45995. */
  45996. getClassName(): string;
  45997. }
  45998. }
  45999. declare module BABYLON {
  46000. /**
  46001. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46002. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46003. */
  46004. export class AnaglyphUniversalCamera extends UniversalCamera {
  46005. /**
  46006. * Creates a new AnaglyphUniversalCamera
  46007. * @param name defines camera name
  46008. * @param position defines initial position
  46009. * @param interaxialDistance defines distance between each color axis
  46010. * @param scene defines the hosting scene
  46011. */
  46012. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46013. /**
  46014. * Gets camera class name
  46015. * @returns AnaglyphUniversalCamera
  46016. */
  46017. getClassName(): string;
  46018. }
  46019. }
  46020. declare module BABYLON {
  46021. /**
  46022. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46023. * @see https://doc.babylonjs.com/features/cameras
  46024. */
  46025. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46026. /**
  46027. * Creates a new StereoscopicArcRotateCamera
  46028. * @param name defines camera name
  46029. * @param alpha defines alpha angle (in radians)
  46030. * @param beta defines beta angle (in radians)
  46031. * @param radius defines radius
  46032. * @param target defines camera target
  46033. * @param interaxialDistance defines distance between each color axis
  46034. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46035. * @param scene defines the hosting scene
  46036. */
  46037. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46038. /**
  46039. * Gets camera class name
  46040. * @returns StereoscopicArcRotateCamera
  46041. */
  46042. getClassName(): string;
  46043. }
  46044. }
  46045. declare module BABYLON {
  46046. /**
  46047. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46048. * @see https://doc.babylonjs.com/features/cameras
  46049. */
  46050. export class StereoscopicFreeCamera extends FreeCamera {
  46051. /**
  46052. * Creates a new StereoscopicFreeCamera
  46053. * @param name defines camera name
  46054. * @param position defines initial position
  46055. * @param interaxialDistance defines distance between each color axis
  46056. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46057. * @param scene defines the hosting scene
  46058. */
  46059. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46060. /**
  46061. * Gets camera class name
  46062. * @returns StereoscopicFreeCamera
  46063. */
  46064. getClassName(): string;
  46065. }
  46066. }
  46067. declare module BABYLON {
  46068. /**
  46069. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46070. * @see https://doc.babylonjs.com/features/cameras
  46071. */
  46072. export class StereoscopicGamepadCamera extends GamepadCamera {
  46073. /**
  46074. * Creates a new StereoscopicGamepadCamera
  46075. * @param name defines camera name
  46076. * @param position defines initial position
  46077. * @param interaxialDistance defines distance between each color axis
  46078. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46079. * @param scene defines the hosting scene
  46080. */
  46081. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46082. /**
  46083. * Gets camera class name
  46084. * @returns StereoscopicGamepadCamera
  46085. */
  46086. getClassName(): string;
  46087. }
  46088. }
  46089. declare module BABYLON {
  46090. /**
  46091. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46092. * @see https://doc.babylonjs.com/features/cameras
  46093. */
  46094. export class StereoscopicUniversalCamera extends UniversalCamera {
  46095. /**
  46096. * Creates a new StereoscopicUniversalCamera
  46097. * @param name defines camera name
  46098. * @param position defines initial position
  46099. * @param interaxialDistance defines distance between each color axis
  46100. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46101. * @param scene defines the hosting scene
  46102. */
  46103. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46104. /**
  46105. * Gets camera class name
  46106. * @returns StereoscopicUniversalCamera
  46107. */
  46108. getClassName(): string;
  46109. }
  46110. }
  46111. declare module BABYLON {
  46112. /**
  46113. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46114. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46115. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46116. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46117. */
  46118. export class VirtualJoysticksCamera extends FreeCamera {
  46119. /**
  46120. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46121. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46122. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46123. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46124. * @param name Define the name of the camera in the scene
  46125. * @param position Define the start position of the camera in the scene
  46126. * @param scene Define the scene the camera belongs to
  46127. */
  46128. constructor(name: string, position: Vector3, scene: Scene);
  46129. /**
  46130. * Gets the current object class name.
  46131. * @return the class name
  46132. */
  46133. getClassName(): string;
  46134. }
  46135. }
  46136. declare module BABYLON {
  46137. /**
  46138. * This represents all the required metrics to create a VR camera.
  46139. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46140. */
  46141. export class VRCameraMetrics {
  46142. /**
  46143. * Define the horizontal resolution off the screen.
  46144. */
  46145. hResolution: number;
  46146. /**
  46147. * Define the vertical resolution off the screen.
  46148. */
  46149. vResolution: number;
  46150. /**
  46151. * Define the horizontal screen size.
  46152. */
  46153. hScreenSize: number;
  46154. /**
  46155. * Define the vertical screen size.
  46156. */
  46157. vScreenSize: number;
  46158. /**
  46159. * Define the vertical screen center position.
  46160. */
  46161. vScreenCenter: number;
  46162. /**
  46163. * Define the distance of the eyes to the screen.
  46164. */
  46165. eyeToScreenDistance: number;
  46166. /**
  46167. * Define the distance between both lenses
  46168. */
  46169. lensSeparationDistance: number;
  46170. /**
  46171. * Define the distance between both viewer's eyes.
  46172. */
  46173. interpupillaryDistance: number;
  46174. /**
  46175. * Define the distortion factor of the VR postprocess.
  46176. * Please, touch with care.
  46177. */
  46178. distortionK: number[];
  46179. /**
  46180. * Define the chromatic aberration correction factors for the VR post process.
  46181. */
  46182. chromaAbCorrection: number[];
  46183. /**
  46184. * Define the scale factor of the post process.
  46185. * The smaller the better but the slower.
  46186. */
  46187. postProcessScaleFactor: number;
  46188. /**
  46189. * Define an offset for the lens center.
  46190. */
  46191. lensCenterOffset: number;
  46192. /**
  46193. * Define if the current vr camera should compensate the distortion of the lense or not.
  46194. */
  46195. compensateDistortion: boolean;
  46196. /**
  46197. * Defines if multiview should be enabled when rendering (Default: false)
  46198. */
  46199. multiviewEnabled: boolean;
  46200. /**
  46201. * Gets the rendering aspect ratio based on the provided resolutions.
  46202. */
  46203. get aspectRatio(): number;
  46204. /**
  46205. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46206. */
  46207. get aspectRatioFov(): number;
  46208. /**
  46209. * @hidden
  46210. */
  46211. get leftHMatrix(): Matrix;
  46212. /**
  46213. * @hidden
  46214. */
  46215. get rightHMatrix(): Matrix;
  46216. /**
  46217. * @hidden
  46218. */
  46219. get leftPreViewMatrix(): Matrix;
  46220. /**
  46221. * @hidden
  46222. */
  46223. get rightPreViewMatrix(): Matrix;
  46224. /**
  46225. * Get the default VRMetrics based on the most generic setup.
  46226. * @returns the default vr metrics
  46227. */
  46228. static GetDefault(): VRCameraMetrics;
  46229. }
  46230. }
  46231. declare module BABYLON {
  46232. /** @hidden */
  46233. export var vrDistortionCorrectionPixelShader: {
  46234. name: string;
  46235. shader: string;
  46236. };
  46237. }
  46238. declare module BABYLON {
  46239. /**
  46240. * VRDistortionCorrectionPostProcess used for mobile VR
  46241. */
  46242. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46243. private _isRightEye;
  46244. private _distortionFactors;
  46245. private _postProcessScaleFactor;
  46246. private _lensCenterOffset;
  46247. private _scaleIn;
  46248. private _scaleFactor;
  46249. private _lensCenter;
  46250. /**
  46251. * Initializes the VRDistortionCorrectionPostProcess
  46252. * @param name The name of the effect.
  46253. * @param camera The camera to apply the render pass to.
  46254. * @param isRightEye If this is for the right eye distortion
  46255. * @param vrMetrics All the required metrics for the VR camera
  46256. */
  46257. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46258. }
  46259. }
  46260. declare module BABYLON {
  46261. /**
  46262. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46263. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46264. */
  46265. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46266. /**
  46267. * Creates a new VRDeviceOrientationArcRotateCamera
  46268. * @param name defines camera name
  46269. * @param alpha defines the camera rotation along the logitudinal axis
  46270. * @param beta defines the camera rotation along the latitudinal axis
  46271. * @param radius defines the camera distance from its target
  46272. * @param target defines the camera target
  46273. * @param scene defines the scene the camera belongs to
  46274. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46275. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46276. */
  46277. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46278. /**
  46279. * Gets camera class name
  46280. * @returns VRDeviceOrientationArcRotateCamera
  46281. */
  46282. getClassName(): string;
  46283. }
  46284. }
  46285. declare module BABYLON {
  46286. /**
  46287. * Camera used to simulate VR rendering (based on FreeCamera)
  46288. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46289. */
  46290. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46291. /**
  46292. * Creates a new VRDeviceOrientationFreeCamera
  46293. * @param name defines camera name
  46294. * @param position defines the start position of the camera
  46295. * @param scene defines the scene the camera belongs to
  46296. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46297. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46298. */
  46299. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46300. /**
  46301. * Gets camera class name
  46302. * @returns VRDeviceOrientationFreeCamera
  46303. */
  46304. getClassName(): string;
  46305. }
  46306. }
  46307. declare module BABYLON {
  46308. /**
  46309. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46310. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46311. */
  46312. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46313. /**
  46314. * Creates a new VRDeviceOrientationGamepadCamera
  46315. * @param name defines camera name
  46316. * @param position defines the start position of the camera
  46317. * @param scene defines the scene the camera belongs to
  46318. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46319. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46320. */
  46321. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46322. /**
  46323. * Gets camera class name
  46324. * @returns VRDeviceOrientationGamepadCamera
  46325. */
  46326. getClassName(): string;
  46327. }
  46328. }
  46329. declare module BABYLON {
  46330. /**
  46331. * A class extending Texture allowing drawing on a texture
  46332. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46333. */
  46334. export class DynamicTexture extends Texture {
  46335. private _generateMipMaps;
  46336. private _canvas;
  46337. private _context;
  46338. /**
  46339. * Creates a DynamicTexture
  46340. * @param name defines the name of the texture
  46341. * @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
  46342. * @param scene defines the scene where you want the texture
  46343. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46344. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46345. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46346. */
  46347. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46348. /**
  46349. * Get the current class name of the texture useful for serialization or dynamic coding.
  46350. * @returns "DynamicTexture"
  46351. */
  46352. getClassName(): string;
  46353. /**
  46354. * Gets the current state of canRescale
  46355. */
  46356. get canRescale(): boolean;
  46357. private _recreate;
  46358. /**
  46359. * Scales the texture
  46360. * @param ratio the scale factor to apply to both width and height
  46361. */
  46362. scale(ratio: number): void;
  46363. /**
  46364. * Resizes the texture
  46365. * @param width the new width
  46366. * @param height the new height
  46367. */
  46368. scaleTo(width: number, height: number): void;
  46369. /**
  46370. * Gets the context of the canvas used by the texture
  46371. * @returns the canvas context of the dynamic texture
  46372. */
  46373. getContext(): CanvasRenderingContext2D;
  46374. /**
  46375. * Clears the texture
  46376. */
  46377. clear(): void;
  46378. /**
  46379. * Updates the texture
  46380. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46381. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46382. */
  46383. update(invertY?: boolean, premulAlpha?: boolean): void;
  46384. /**
  46385. * Draws text onto the texture
  46386. * @param text defines the text to be drawn
  46387. * @param x defines the placement of the text from the left
  46388. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46389. * @param font defines the font to be used with font-style, font-size, font-name
  46390. * @param color defines the color used for the text
  46391. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46392. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46393. * @param update defines whether texture is immediately update (default is true)
  46394. */
  46395. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46396. /**
  46397. * Clones the texture
  46398. * @returns the clone of the texture.
  46399. */
  46400. clone(): DynamicTexture;
  46401. /**
  46402. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46403. * @returns a serialized dynamic texture object
  46404. */
  46405. serialize(): any;
  46406. private _IsCanvasElement;
  46407. /** @hidden */
  46408. _rebuild(): void;
  46409. }
  46410. }
  46411. declare module BABYLON {
  46412. /**
  46413. * Class containing static functions to help procedurally build meshes
  46414. */
  46415. export class GroundBuilder {
  46416. /**
  46417. * Creates a ground mesh
  46418. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46419. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46421. * @param name defines the name of the mesh
  46422. * @param options defines the options used to create the mesh
  46423. * @param scene defines the hosting scene
  46424. * @returns the ground mesh
  46425. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46426. */
  46427. static CreateGround(name: string, options: {
  46428. width?: number;
  46429. height?: number;
  46430. subdivisions?: number;
  46431. subdivisionsX?: number;
  46432. subdivisionsY?: number;
  46433. updatable?: boolean;
  46434. }, scene: any): Mesh;
  46435. /**
  46436. * Creates a tiled ground mesh
  46437. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46438. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46439. * * 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
  46440. * * 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
  46441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46442. * @param name defines the name of the mesh
  46443. * @param options defines the options used to create the mesh
  46444. * @param scene defines the hosting scene
  46445. * @returns the tiled ground mesh
  46446. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46447. */
  46448. static CreateTiledGround(name: string, options: {
  46449. xmin: number;
  46450. zmin: number;
  46451. xmax: number;
  46452. zmax: number;
  46453. subdivisions?: {
  46454. w: number;
  46455. h: number;
  46456. };
  46457. precision?: {
  46458. w: number;
  46459. h: number;
  46460. };
  46461. updatable?: boolean;
  46462. }, scene?: Nullable<Scene>): Mesh;
  46463. /**
  46464. * Creates a ground mesh from a height map
  46465. * * The parameter `url` sets the URL of the height map image resource.
  46466. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46467. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46468. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46469. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46470. * * 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.
  46471. * * 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).
  46472. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46474. * @param name defines the name of the mesh
  46475. * @param url defines the url to the height map
  46476. * @param options defines the options used to create the mesh
  46477. * @param scene defines the hosting scene
  46478. * @returns the ground mesh
  46479. * @see https://doc.babylonjs.com/babylon101/height_map
  46480. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46481. */
  46482. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46483. width?: number;
  46484. height?: number;
  46485. subdivisions?: number;
  46486. minHeight?: number;
  46487. maxHeight?: number;
  46488. colorFilter?: Color3;
  46489. alphaFilter?: number;
  46490. updatable?: boolean;
  46491. onReady?: (mesh: GroundMesh) => void;
  46492. }, scene?: Nullable<Scene>): GroundMesh;
  46493. }
  46494. }
  46495. declare module BABYLON {
  46496. /**
  46497. * Class containing static functions to help procedurally build meshes
  46498. */
  46499. export class TorusBuilder {
  46500. /**
  46501. * Creates a torus mesh
  46502. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46503. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46504. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46506. * * 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
  46507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46508. * @param name defines the name of the mesh
  46509. * @param options defines the options used to create the mesh
  46510. * @param scene defines the hosting scene
  46511. * @returns the torus mesh
  46512. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46513. */
  46514. static CreateTorus(name: string, options: {
  46515. diameter?: number;
  46516. thickness?: number;
  46517. tessellation?: number;
  46518. updatable?: boolean;
  46519. sideOrientation?: number;
  46520. frontUVs?: Vector4;
  46521. backUVs?: Vector4;
  46522. }, scene: any): Mesh;
  46523. }
  46524. }
  46525. declare module BABYLON {
  46526. /**
  46527. * Class containing static functions to help procedurally build meshes
  46528. */
  46529. export class CylinderBuilder {
  46530. /**
  46531. * Creates a cylinder or a cone mesh
  46532. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46533. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46534. * * 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.
  46535. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46536. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46537. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46538. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46539. * * 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).
  46540. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46541. * * 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).
  46542. * * 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
  46543. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46544. * * 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
  46545. * * 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.
  46546. * * If `enclose` is false, a ring surface is one element.
  46547. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46548. * * 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
  46549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46550. * * 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
  46551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46552. * @param name defines the name of the mesh
  46553. * @param options defines the options used to create the mesh
  46554. * @param scene defines the hosting scene
  46555. * @returns the cylinder mesh
  46556. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46557. */
  46558. static CreateCylinder(name: string, options: {
  46559. height?: number;
  46560. diameterTop?: number;
  46561. diameterBottom?: number;
  46562. diameter?: number;
  46563. tessellation?: number;
  46564. subdivisions?: number;
  46565. arc?: number;
  46566. faceColors?: Color4[];
  46567. faceUV?: Vector4[];
  46568. updatable?: boolean;
  46569. hasRings?: boolean;
  46570. enclose?: boolean;
  46571. cap?: number;
  46572. sideOrientation?: number;
  46573. frontUVs?: Vector4;
  46574. backUVs?: Vector4;
  46575. }, scene: any): Mesh;
  46576. }
  46577. }
  46578. declare module BABYLON {
  46579. /**
  46580. * States of the webXR experience
  46581. */
  46582. export enum WebXRState {
  46583. /**
  46584. * Transitioning to being in XR mode
  46585. */
  46586. ENTERING_XR = 0,
  46587. /**
  46588. * Transitioning to non XR mode
  46589. */
  46590. EXITING_XR = 1,
  46591. /**
  46592. * In XR mode and presenting
  46593. */
  46594. IN_XR = 2,
  46595. /**
  46596. * Not entered XR mode
  46597. */
  46598. NOT_IN_XR = 3
  46599. }
  46600. /**
  46601. * Abstraction of the XR render target
  46602. */
  46603. export interface WebXRRenderTarget extends IDisposable {
  46604. /**
  46605. * xrpresent context of the canvas which can be used to display/mirror xr content
  46606. */
  46607. canvasContext: WebGLRenderingContext;
  46608. /**
  46609. * xr layer for the canvas
  46610. */
  46611. xrLayer: Nullable<XRWebGLLayer>;
  46612. /**
  46613. * Initializes the xr layer for the session
  46614. * @param xrSession xr session
  46615. * @returns a promise that will resolve once the XR Layer has been created
  46616. */
  46617. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46618. }
  46619. }
  46620. declare module BABYLON {
  46621. /**
  46622. * COnfiguration object for WebXR output canvas
  46623. */
  46624. export class WebXRManagedOutputCanvasOptions {
  46625. /**
  46626. * An optional canvas in case you wish to create it yourself and provide it here.
  46627. * If not provided, a new canvas will be created
  46628. */
  46629. canvasElement?: HTMLCanvasElement;
  46630. /**
  46631. * Options for this XR Layer output
  46632. */
  46633. canvasOptions?: XRWebGLLayerOptions;
  46634. /**
  46635. * CSS styling for a newly created canvas (if not provided)
  46636. */
  46637. newCanvasCssStyle?: string;
  46638. /**
  46639. * Get the default values of the configuration object
  46640. * @returns default values of this configuration object
  46641. */
  46642. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46643. }
  46644. /**
  46645. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46646. */
  46647. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46648. private _options;
  46649. private _canvas;
  46650. private _engine;
  46651. private _originalCanvasSize;
  46652. /**
  46653. * Rendering context of the canvas which can be used to display/mirror xr content
  46654. */
  46655. canvasContext: WebGLRenderingContext;
  46656. /**
  46657. * xr layer for the canvas
  46658. */
  46659. xrLayer: Nullable<XRWebGLLayer>;
  46660. /**
  46661. * Obseervers registered here will be triggered when the xr layer was initialized
  46662. */
  46663. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46664. /**
  46665. * Initializes the canvas to be added/removed upon entering/exiting xr
  46666. * @param _xrSessionManager The XR Session manager
  46667. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46668. */
  46669. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46670. /**
  46671. * Disposes of the object
  46672. */
  46673. dispose(): void;
  46674. /**
  46675. * Initializes the xr layer for the session
  46676. * @param xrSession xr session
  46677. * @returns a promise that will resolve once the XR Layer has been created
  46678. */
  46679. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46680. private _addCanvas;
  46681. private _removeCanvas;
  46682. private _setCanvasSize;
  46683. private _setManagedOutputCanvas;
  46684. }
  46685. }
  46686. declare module BABYLON {
  46687. /**
  46688. * Manages an XRSession to work with Babylon's engine
  46689. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46690. */
  46691. export class WebXRSessionManager implements IDisposable {
  46692. /** The scene which the session should be created for */
  46693. scene: Scene;
  46694. private _referenceSpace;
  46695. private _rttProvider;
  46696. private _sessionEnded;
  46697. private _xrNavigator;
  46698. private baseLayer;
  46699. /**
  46700. * The base reference space from which the session started. good if you want to reset your
  46701. * reference space
  46702. */
  46703. baseReferenceSpace: XRReferenceSpace;
  46704. /**
  46705. * Current XR frame
  46706. */
  46707. currentFrame: Nullable<XRFrame>;
  46708. /** WebXR timestamp updated every frame */
  46709. currentTimestamp: number;
  46710. /**
  46711. * Used just in case of a failure to initialize an immersive session.
  46712. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46713. */
  46714. defaultHeightCompensation: number;
  46715. /**
  46716. * Fires every time a new xrFrame arrives which can be used to update the camera
  46717. */
  46718. onXRFrameObservable: Observable<XRFrame>;
  46719. /**
  46720. * Fires when the reference space changed
  46721. */
  46722. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46723. /**
  46724. * Fires when the xr session is ended either by the device or manually done
  46725. */
  46726. onXRSessionEnded: Observable<any>;
  46727. /**
  46728. * Fires when the xr session is ended either by the device or manually done
  46729. */
  46730. onXRSessionInit: Observable<XRSession>;
  46731. /**
  46732. * Underlying xr session
  46733. */
  46734. session: XRSession;
  46735. /**
  46736. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46737. * or get the offset the player is currently at.
  46738. */
  46739. viewerReferenceSpace: XRReferenceSpace;
  46740. /**
  46741. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46742. * @param scene The scene which the session should be created for
  46743. */
  46744. constructor(
  46745. /** The scene which the session should be created for */
  46746. scene: Scene);
  46747. /**
  46748. * The current reference space used in this session. This reference space can constantly change!
  46749. * It is mainly used to offset the camera's position.
  46750. */
  46751. get referenceSpace(): XRReferenceSpace;
  46752. /**
  46753. * Set a new reference space and triggers the observable
  46754. */
  46755. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46756. /**
  46757. * Disposes of the session manager
  46758. */
  46759. dispose(): void;
  46760. /**
  46761. * Stops the xrSession and restores the render loop
  46762. * @returns Promise which resolves after it exits XR
  46763. */
  46764. exitXRAsync(): Promise<void>;
  46765. /**
  46766. * Gets the correct render target texture to be rendered this frame for this eye
  46767. * @param eye the eye for which to get the render target
  46768. * @returns the render target for the specified eye
  46769. */
  46770. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46771. /**
  46772. * Creates a WebXRRenderTarget object for the XR session
  46773. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46774. * @param options optional options to provide when creating a new render target
  46775. * @returns a WebXR render target to which the session can render
  46776. */
  46777. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46778. /**
  46779. * Initializes the manager
  46780. * After initialization enterXR can be called to start an XR session
  46781. * @returns Promise which resolves after it is initialized
  46782. */
  46783. initializeAsync(): Promise<void>;
  46784. /**
  46785. * Initializes an xr session
  46786. * @param xrSessionMode mode to initialize
  46787. * @param xrSessionInit defines optional and required values to pass to the session builder
  46788. * @returns a promise which will resolve once the session has been initialized
  46789. */
  46790. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46791. /**
  46792. * Checks if a session would be supported for the creation options specified
  46793. * @param sessionMode session mode to check if supported eg. immersive-vr
  46794. * @returns A Promise that resolves to true if supported and false if not
  46795. */
  46796. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46797. /**
  46798. * Resets the reference space to the one started the session
  46799. */
  46800. resetReferenceSpace(): void;
  46801. /**
  46802. * Starts rendering to the xr layer
  46803. */
  46804. runXRRenderLoop(): void;
  46805. /**
  46806. * Sets the reference space on the xr session
  46807. * @param referenceSpaceType space to set
  46808. * @returns a promise that will resolve once the reference space has been set
  46809. */
  46810. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46811. /**
  46812. * Updates the render state of the session
  46813. * @param state state to set
  46814. * @returns a promise that resolves once the render state has been updated
  46815. */
  46816. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46817. /**
  46818. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46819. * @param sessionMode defines the session to test
  46820. * @returns a promise with boolean as final value
  46821. */
  46822. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46823. private _createRenderTargetTexture;
  46824. }
  46825. }
  46826. declare module BABYLON {
  46827. /**
  46828. * WebXR Camera which holds the views for the xrSession
  46829. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46830. */
  46831. export class WebXRCamera extends FreeCamera {
  46832. private _xrSessionManager;
  46833. private _firstFrame;
  46834. private _referenceQuaternion;
  46835. private _referencedPosition;
  46836. private _xrInvPositionCache;
  46837. private _xrInvQuaternionCache;
  46838. /**
  46839. * Should position compensation execute on first frame.
  46840. * This is used when copying the position from a native (non XR) camera
  46841. */
  46842. compensateOnFirstFrame: boolean;
  46843. /**
  46844. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46845. * @param name the name of the camera
  46846. * @param scene the scene to add the camera to
  46847. * @param _xrSessionManager a constructed xr session manager
  46848. */
  46849. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46850. /**
  46851. * Return the user's height, unrelated to the current ground.
  46852. * This will be the y position of this camera, when ground level is 0.
  46853. */
  46854. get realWorldHeight(): number;
  46855. /** @hidden */
  46856. _updateForDualEyeDebugging(): void;
  46857. /**
  46858. * Sets this camera's transformation based on a non-vr camera
  46859. * @param otherCamera the non-vr camera to copy the transformation from
  46860. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46861. */
  46862. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46863. /**
  46864. * Gets the current instance class name ("WebXRCamera").
  46865. * @returns the class name
  46866. */
  46867. getClassName(): string;
  46868. private _rotate180;
  46869. private _updateFromXRSession;
  46870. private _updateNumberOfRigCameras;
  46871. private _updateReferenceSpace;
  46872. private _updateReferenceSpaceOffset;
  46873. }
  46874. }
  46875. declare module BABYLON {
  46876. /**
  46877. * Defining the interface required for a (webxr) feature
  46878. */
  46879. export interface IWebXRFeature extends IDisposable {
  46880. /**
  46881. * Is this feature attached
  46882. */
  46883. attached: boolean;
  46884. /**
  46885. * Should auto-attach be disabled?
  46886. */
  46887. disableAutoAttach: boolean;
  46888. /**
  46889. * Attach the feature to the session
  46890. * Will usually be called by the features manager
  46891. *
  46892. * @param force should attachment be forced (even when already attached)
  46893. * @returns true if successful.
  46894. */
  46895. attach(force?: boolean): boolean;
  46896. /**
  46897. * Detach the feature from the session
  46898. * Will usually be called by the features manager
  46899. *
  46900. * @returns true if successful.
  46901. */
  46902. detach(): boolean;
  46903. /**
  46904. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46905. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46906. *
  46907. * @returns whether or not the feature is compatible in this environment
  46908. */
  46909. isCompatible(): boolean;
  46910. /**
  46911. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46912. */
  46913. xrNativeFeatureName?: string;
  46914. }
  46915. /**
  46916. * A list of the currently available features without referencing them
  46917. */
  46918. export class WebXRFeatureName {
  46919. /**
  46920. * The name of the anchor system feature
  46921. */
  46922. static ANCHOR_SYSTEM: string;
  46923. /**
  46924. * The name of the background remover feature
  46925. */
  46926. static BACKGROUND_REMOVER: string;
  46927. /**
  46928. * The name of the hit test feature
  46929. */
  46930. static HIT_TEST: string;
  46931. /**
  46932. * physics impostors for xr controllers feature
  46933. */
  46934. static PHYSICS_CONTROLLERS: string;
  46935. /**
  46936. * The name of the plane detection feature
  46937. */
  46938. static PLANE_DETECTION: string;
  46939. /**
  46940. * The name of the pointer selection feature
  46941. */
  46942. static POINTER_SELECTION: string;
  46943. /**
  46944. * The name of the teleportation feature
  46945. */
  46946. static TELEPORTATION: string;
  46947. }
  46948. /**
  46949. * Defining the constructor of a feature. Used to register the modules.
  46950. */
  46951. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46952. /**
  46953. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46954. * It is mainly used in AR sessions.
  46955. *
  46956. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46957. */
  46958. export class WebXRFeaturesManager implements IDisposable {
  46959. private _xrSessionManager;
  46960. private static readonly _AvailableFeatures;
  46961. private _features;
  46962. /**
  46963. * constructs a new features manages.
  46964. *
  46965. * @param _xrSessionManager an instance of WebXRSessionManager
  46966. */
  46967. constructor(_xrSessionManager: WebXRSessionManager);
  46968. /**
  46969. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46970. * Mainly used internally.
  46971. *
  46972. * @param featureName the name of the feature to register
  46973. * @param constructorFunction the function used to construct the module
  46974. * @param version the (babylon) version of the module
  46975. * @param stable is that a stable version of this module
  46976. */
  46977. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46978. /**
  46979. * Returns a constructor of a specific feature.
  46980. *
  46981. * @param featureName the name of the feature to construct
  46982. * @param version the version of the feature to load
  46983. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46984. * @param options optional options provided to the module.
  46985. * @returns a function that, when called, will return a new instance of this feature
  46986. */
  46987. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46988. /**
  46989. * Can be used to return the list of features currently registered
  46990. *
  46991. * @returns an Array of available features
  46992. */
  46993. static GetAvailableFeatures(): string[];
  46994. /**
  46995. * Gets the versions available for a specific feature
  46996. * @param featureName the name of the feature
  46997. * @returns an array with the available versions
  46998. */
  46999. static GetAvailableVersions(featureName: string): string[];
  47000. /**
  47001. * Return the latest unstable version of this feature
  47002. * @param featureName the name of the feature to search
  47003. * @returns the version number. if not found will return -1
  47004. */
  47005. static GetLatestVersionOfFeature(featureName: string): number;
  47006. /**
  47007. * Return the latest stable version of this feature
  47008. * @param featureName the name of the feature to search
  47009. * @returns the version number. if not found will return -1
  47010. */
  47011. static GetStableVersionOfFeature(featureName: string): number;
  47012. /**
  47013. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47014. * Can be used during a session to start a feature
  47015. * @param featureName the name of feature to attach
  47016. */
  47017. attachFeature(featureName: string): void;
  47018. /**
  47019. * Can be used inside a session or when the session ends to detach a specific feature
  47020. * @param featureName the name of the feature to detach
  47021. */
  47022. detachFeature(featureName: string): void;
  47023. /**
  47024. * Used to disable an already-enabled feature
  47025. * The feature will be disposed and will be recreated once enabled.
  47026. * @param featureName the feature to disable
  47027. * @returns true if disable was successful
  47028. */
  47029. disableFeature(featureName: string | {
  47030. Name: string;
  47031. }): boolean;
  47032. /**
  47033. * dispose this features manager
  47034. */
  47035. dispose(): void;
  47036. /**
  47037. * 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.
  47038. * 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.
  47039. *
  47040. * @param featureName the name of the feature to load or the class of the feature
  47041. * @param version optional version to load. if not provided the latest version will be enabled
  47042. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47043. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47044. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47045. * @returns a new constructed feature or throws an error if feature not found.
  47046. */
  47047. enableFeature(featureName: string | {
  47048. Name: string;
  47049. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47050. /**
  47051. * get the implementation of an enabled feature.
  47052. * @param featureName the name of the feature to load
  47053. * @returns the feature class, if found
  47054. */
  47055. getEnabledFeature(featureName: string): IWebXRFeature;
  47056. /**
  47057. * Get the list of enabled features
  47058. * @returns an array of enabled features
  47059. */
  47060. getEnabledFeatures(): string[];
  47061. /**
  47062. * This function will exten the session creation configuration object with enabled features.
  47063. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47064. * according to the defined "required" variable, provided during enableFeature call
  47065. * @param xrSessionInit the xr Session init object to extend
  47066. *
  47067. * @returns an extended XRSessionInit object
  47068. */
  47069. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47070. }
  47071. }
  47072. declare module BABYLON {
  47073. /**
  47074. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47075. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47076. */
  47077. export class WebXRExperienceHelper implements IDisposable {
  47078. private scene;
  47079. private _nonVRCamera;
  47080. private _originalSceneAutoClear;
  47081. private _supported;
  47082. /**
  47083. * Camera used to render xr content
  47084. */
  47085. camera: WebXRCamera;
  47086. /** A features manager for this xr session */
  47087. featuresManager: WebXRFeaturesManager;
  47088. /**
  47089. * Observers registered here will be triggered after the camera's initial transformation is set
  47090. * This can be used to set a different ground level or an extra rotation.
  47091. *
  47092. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47093. * to the position set after this observable is done executing.
  47094. */
  47095. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47096. /**
  47097. * Fires when the state of the experience helper has changed
  47098. */
  47099. onStateChangedObservable: Observable<WebXRState>;
  47100. /** Session manager used to keep track of xr session */
  47101. sessionManager: WebXRSessionManager;
  47102. /**
  47103. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47104. */
  47105. state: WebXRState;
  47106. /**
  47107. * Creates a WebXRExperienceHelper
  47108. * @param scene The scene the helper should be created in
  47109. */
  47110. private constructor();
  47111. /**
  47112. * Creates the experience helper
  47113. * @param scene the scene to attach the experience helper to
  47114. * @returns a promise for the experience helper
  47115. */
  47116. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47117. /**
  47118. * Disposes of the experience helper
  47119. */
  47120. dispose(): void;
  47121. /**
  47122. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47123. * @param sessionMode options for the XR session
  47124. * @param referenceSpaceType frame of reference of the XR session
  47125. * @param renderTarget the output canvas that will be used to enter XR mode
  47126. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47127. * @returns promise that resolves after xr mode has entered
  47128. */
  47129. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47130. /**
  47131. * Exits XR mode and returns the scene to its original state
  47132. * @returns promise that resolves after xr mode has exited
  47133. */
  47134. exitXRAsync(): Promise<void>;
  47135. private _nonXRToXRCamera;
  47136. private _setState;
  47137. }
  47138. }
  47139. declare module BABYLON {
  47140. /**
  47141. * X-Y values for axes in WebXR
  47142. */
  47143. export interface IWebXRMotionControllerAxesValue {
  47144. /**
  47145. * The value of the x axis
  47146. */
  47147. x: number;
  47148. /**
  47149. * The value of the y-axis
  47150. */
  47151. y: number;
  47152. }
  47153. /**
  47154. * changed / previous values for the values of this component
  47155. */
  47156. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47157. /**
  47158. * current (this frame) value
  47159. */
  47160. current: T;
  47161. /**
  47162. * previous (last change) value
  47163. */
  47164. previous: T;
  47165. }
  47166. /**
  47167. * Represents changes in the component between current frame and last values recorded
  47168. */
  47169. export interface IWebXRMotionControllerComponentChanges {
  47170. /**
  47171. * will be populated with previous and current values if axes changed
  47172. */
  47173. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47174. /**
  47175. * will be populated with previous and current values if pressed changed
  47176. */
  47177. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47178. /**
  47179. * will be populated with previous and current values if touched changed
  47180. */
  47181. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47182. /**
  47183. * will be populated with previous and current values if value changed
  47184. */
  47185. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47186. }
  47187. /**
  47188. * This class represents a single component (for example button or thumbstick) of a motion controller
  47189. */
  47190. export class WebXRControllerComponent implements IDisposable {
  47191. /**
  47192. * the id of this component
  47193. */
  47194. id: string;
  47195. /**
  47196. * the type of the component
  47197. */
  47198. type: MotionControllerComponentType;
  47199. private _buttonIndex;
  47200. private _axesIndices;
  47201. private _axes;
  47202. private _changes;
  47203. private _currentValue;
  47204. private _hasChanges;
  47205. private _pressed;
  47206. private _touched;
  47207. /**
  47208. * button component type
  47209. */
  47210. static BUTTON_TYPE: MotionControllerComponentType;
  47211. /**
  47212. * squeeze component type
  47213. */
  47214. static SQUEEZE_TYPE: MotionControllerComponentType;
  47215. /**
  47216. * Thumbstick component type
  47217. */
  47218. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47219. /**
  47220. * Touchpad component type
  47221. */
  47222. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47223. /**
  47224. * trigger component type
  47225. */
  47226. static TRIGGER_TYPE: MotionControllerComponentType;
  47227. /**
  47228. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47229. * the axes data changes
  47230. */
  47231. onAxisValueChangedObservable: Observable<{
  47232. x: number;
  47233. y: number;
  47234. }>;
  47235. /**
  47236. * Observers registered here will be triggered when the state of a button changes
  47237. * State change is either pressed / touched / value
  47238. */
  47239. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47240. /**
  47241. * Creates a new component for a motion controller.
  47242. * It is created by the motion controller itself
  47243. *
  47244. * @param id the id of this component
  47245. * @param type the type of the component
  47246. * @param _buttonIndex index in the buttons array of the gamepad
  47247. * @param _axesIndices indices of the values in the axes array of the gamepad
  47248. */
  47249. constructor(
  47250. /**
  47251. * the id of this component
  47252. */
  47253. id: string,
  47254. /**
  47255. * the type of the component
  47256. */
  47257. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47258. /**
  47259. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47260. */
  47261. get axes(): IWebXRMotionControllerAxesValue;
  47262. /**
  47263. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47264. */
  47265. get changes(): IWebXRMotionControllerComponentChanges;
  47266. /**
  47267. * Return whether or not the component changed the last frame
  47268. */
  47269. get hasChanges(): boolean;
  47270. /**
  47271. * is the button currently pressed
  47272. */
  47273. get pressed(): boolean;
  47274. /**
  47275. * is the button currently touched
  47276. */
  47277. get touched(): boolean;
  47278. /**
  47279. * Get the current value of this component
  47280. */
  47281. get value(): number;
  47282. /**
  47283. * Dispose this component
  47284. */
  47285. dispose(): void;
  47286. /**
  47287. * Are there axes correlating to this component
  47288. * @return true is axes data is available
  47289. */
  47290. isAxes(): boolean;
  47291. /**
  47292. * Is this component a button (hence - pressable)
  47293. * @returns true if can be pressed
  47294. */
  47295. isButton(): boolean;
  47296. /**
  47297. * update this component using the gamepad object it is in. Called on every frame
  47298. * @param nativeController the native gamepad controller object
  47299. */
  47300. update(nativeController: IMinimalMotionControllerObject): void;
  47301. }
  47302. }
  47303. declare module BABYLON {
  47304. /**
  47305. * Interface used to represent data loading progression
  47306. */
  47307. export interface ISceneLoaderProgressEvent {
  47308. /**
  47309. * Defines if data length to load can be evaluated
  47310. */
  47311. readonly lengthComputable: boolean;
  47312. /**
  47313. * Defines the loaded data length
  47314. */
  47315. readonly loaded: number;
  47316. /**
  47317. * Defines the data length to load
  47318. */
  47319. readonly total: number;
  47320. }
  47321. /**
  47322. * Interface used by SceneLoader plugins to define supported file extensions
  47323. */
  47324. export interface ISceneLoaderPluginExtensions {
  47325. /**
  47326. * Defines the list of supported extensions
  47327. */
  47328. [extension: string]: {
  47329. isBinary: boolean;
  47330. };
  47331. }
  47332. /**
  47333. * Interface used by SceneLoader plugin factory
  47334. */
  47335. export interface ISceneLoaderPluginFactory {
  47336. /**
  47337. * Defines the name of the factory
  47338. */
  47339. name: string;
  47340. /**
  47341. * Function called to create a new plugin
  47342. * @return the new plugin
  47343. */
  47344. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47345. /**
  47346. * The callback that returns true if the data can be directly loaded.
  47347. * @param data string containing the file data
  47348. * @returns if the data can be loaded directly
  47349. */
  47350. canDirectLoad?(data: string): boolean;
  47351. }
  47352. /**
  47353. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47354. */
  47355. export interface ISceneLoaderPluginBase {
  47356. /**
  47357. * The friendly name of this plugin.
  47358. */
  47359. name: string;
  47360. /**
  47361. * The file extensions supported by this plugin.
  47362. */
  47363. extensions: string | ISceneLoaderPluginExtensions;
  47364. /**
  47365. * The callback called when loading from a url.
  47366. * @param scene scene loading this url
  47367. * @param url url to load
  47368. * @param onSuccess callback called when the file successfully loads
  47369. * @param onProgress callback called while file is loading (if the server supports this mode)
  47370. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47371. * @param onError callback called when the file fails to load
  47372. * @returns a file request object
  47373. */
  47374. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47375. /**
  47376. * The callback called when loading from a file object.
  47377. * @param scene scene loading this file
  47378. * @param file defines the file to load
  47379. * @param onSuccess defines the callback to call when data is loaded
  47380. * @param onProgress defines the callback to call during loading process
  47381. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47382. * @param onError defines the callback to call when an error occurs
  47383. * @returns a file request object
  47384. */
  47385. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47386. /**
  47387. * The callback that returns true if the data can be directly loaded.
  47388. * @param data string containing the file data
  47389. * @returns if the data can be loaded directly
  47390. */
  47391. canDirectLoad?(data: string): boolean;
  47392. /**
  47393. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47394. * @param scene scene loading this data
  47395. * @param data string containing the data
  47396. * @returns data to pass to the plugin
  47397. */
  47398. directLoad?(scene: Scene, data: string): any;
  47399. /**
  47400. * The callback that allows custom handling of the root url based on the response url.
  47401. * @param rootUrl the original root url
  47402. * @param responseURL the response url if available
  47403. * @returns the new root url
  47404. */
  47405. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47406. }
  47407. /**
  47408. * Interface used to define a SceneLoader plugin
  47409. */
  47410. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47411. /**
  47412. * Import meshes into a scene.
  47413. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47414. * @param scene The scene to import into
  47415. * @param data The data to import
  47416. * @param rootUrl The root url for scene and resources
  47417. * @param meshes The meshes array to import into
  47418. * @param particleSystems The particle systems array to import into
  47419. * @param skeletons The skeletons array to import into
  47420. * @param onError The callback when import fails
  47421. * @returns True if successful or false otherwise
  47422. */
  47423. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47424. /**
  47425. * Load into a scene.
  47426. * @param scene The scene to load into
  47427. * @param data The data to import
  47428. * @param rootUrl The root url for scene and resources
  47429. * @param onError The callback when import fails
  47430. * @returns True if successful or false otherwise
  47431. */
  47432. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47433. /**
  47434. * Load into an asset container.
  47435. * @param scene The scene to load into
  47436. * @param data The data to import
  47437. * @param rootUrl The root url for scene and resources
  47438. * @param onError The callback when import fails
  47439. * @returns The loaded asset container
  47440. */
  47441. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47442. }
  47443. /**
  47444. * Interface used to define an async SceneLoader plugin
  47445. */
  47446. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47447. /**
  47448. * Import meshes into a scene.
  47449. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47450. * @param scene The scene to import into
  47451. * @param data The data to import
  47452. * @param rootUrl The root url for scene and resources
  47453. * @param onProgress The callback when the load progresses
  47454. * @param fileName Defines the name of the file to load
  47455. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47456. */
  47457. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47458. meshes: AbstractMesh[];
  47459. particleSystems: IParticleSystem[];
  47460. skeletons: Skeleton[];
  47461. animationGroups: AnimationGroup[];
  47462. }>;
  47463. /**
  47464. * Load into a scene.
  47465. * @param scene The scene to load into
  47466. * @param data The data to import
  47467. * @param rootUrl The root url for scene and resources
  47468. * @param onProgress The callback when the load progresses
  47469. * @param fileName Defines the name of the file to load
  47470. * @returns Nothing
  47471. */
  47472. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47473. /**
  47474. * Load into an asset container.
  47475. * @param scene The scene to load into
  47476. * @param data The data to import
  47477. * @param rootUrl The root url for scene and resources
  47478. * @param onProgress The callback when the load progresses
  47479. * @param fileName Defines the name of the file to load
  47480. * @returns The loaded asset container
  47481. */
  47482. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47483. }
  47484. /**
  47485. * Mode that determines how to handle old animation groups before loading new ones.
  47486. */
  47487. export enum SceneLoaderAnimationGroupLoadingMode {
  47488. /**
  47489. * Reset all old animations to initial state then dispose them.
  47490. */
  47491. Clean = 0,
  47492. /**
  47493. * Stop all old animations.
  47494. */
  47495. Stop = 1,
  47496. /**
  47497. * Restart old animations from first frame.
  47498. */
  47499. Sync = 2,
  47500. /**
  47501. * Old animations remains untouched.
  47502. */
  47503. NoSync = 3
  47504. }
  47505. /**
  47506. * Defines a plugin registered by the SceneLoader
  47507. */
  47508. interface IRegisteredPlugin {
  47509. /**
  47510. * Defines the plugin to use
  47511. */
  47512. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47513. /**
  47514. * Defines if the plugin supports binary data
  47515. */
  47516. isBinary: boolean;
  47517. }
  47518. /**
  47519. * Class used to load scene from various file formats using registered plugins
  47520. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47521. */
  47522. export class SceneLoader {
  47523. /**
  47524. * No logging while loading
  47525. */
  47526. static readonly NO_LOGGING: number;
  47527. /**
  47528. * Minimal logging while loading
  47529. */
  47530. static readonly MINIMAL_LOGGING: number;
  47531. /**
  47532. * Summary logging while loading
  47533. */
  47534. static readonly SUMMARY_LOGGING: number;
  47535. /**
  47536. * Detailled logging while loading
  47537. */
  47538. static readonly DETAILED_LOGGING: number;
  47539. /**
  47540. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47541. */
  47542. static get ForceFullSceneLoadingForIncremental(): boolean;
  47543. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47544. /**
  47545. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47546. */
  47547. static get ShowLoadingScreen(): boolean;
  47548. static set ShowLoadingScreen(value: boolean);
  47549. /**
  47550. * Defines the current logging level (while loading the scene)
  47551. * @ignorenaming
  47552. */
  47553. static get loggingLevel(): number;
  47554. static set loggingLevel(value: number);
  47555. /**
  47556. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47557. */
  47558. static get CleanBoneMatrixWeights(): boolean;
  47559. static set CleanBoneMatrixWeights(value: boolean);
  47560. /**
  47561. * Event raised when a plugin is used to load a scene
  47562. */
  47563. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47564. private static _registeredPlugins;
  47565. private static _showingLoadingScreen;
  47566. /**
  47567. * Gets the default plugin (used to load Babylon files)
  47568. * @returns the .babylon plugin
  47569. */
  47570. static GetDefaultPlugin(): IRegisteredPlugin;
  47571. private static _GetPluginForExtension;
  47572. private static _GetPluginForDirectLoad;
  47573. private static _GetPluginForFilename;
  47574. private static _GetDirectLoad;
  47575. private static _LoadData;
  47576. private static _GetFileInfo;
  47577. /**
  47578. * Gets a plugin that can load the given extension
  47579. * @param extension defines the extension to load
  47580. * @returns a plugin or null if none works
  47581. */
  47582. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47583. /**
  47584. * Gets a boolean indicating that the given extension can be loaded
  47585. * @param extension defines the extension to load
  47586. * @returns true if the extension is supported
  47587. */
  47588. static IsPluginForExtensionAvailable(extension: string): boolean;
  47589. /**
  47590. * Adds a new plugin to the list of registered plugins
  47591. * @param plugin defines the plugin to add
  47592. */
  47593. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47594. /**
  47595. * Import meshes into a scene
  47596. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47597. * @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)
  47598. * @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)
  47599. * @param scene the instance of BABYLON.Scene to append to
  47600. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47601. * @param onProgress a callback with a progress event for each file being loaded
  47602. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47603. * @param pluginExtension the extension used to determine the plugin
  47604. * @returns The loaded plugin
  47605. */
  47606. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47607. /**
  47608. * Import meshes into a scene
  47609. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47610. * @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)
  47611. * @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)
  47612. * @param scene the instance of BABYLON.Scene to append to
  47613. * @param onProgress a callback with a progress event for each file being loaded
  47614. * @param pluginExtension the extension used to determine the plugin
  47615. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47616. */
  47617. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47618. meshes: AbstractMesh[];
  47619. particleSystems: IParticleSystem[];
  47620. skeletons: Skeleton[];
  47621. animationGroups: AnimationGroup[];
  47622. }>;
  47623. /**
  47624. * Load a scene
  47625. * @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)
  47626. * @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)
  47627. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47628. * @param onSuccess a callback with the scene when import succeeds
  47629. * @param onProgress a callback with a progress event for each file being loaded
  47630. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47631. * @param pluginExtension the extension used to determine the plugin
  47632. * @returns The loaded plugin
  47633. */
  47634. 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>;
  47635. /**
  47636. * Load a scene
  47637. * @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)
  47638. * @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)
  47639. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47640. * @param onProgress a callback with a progress event for each file being loaded
  47641. * @param pluginExtension the extension used to determine the plugin
  47642. * @returns The loaded scene
  47643. */
  47644. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47645. /**
  47646. * Append a scene
  47647. * @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)
  47648. * @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)
  47649. * @param scene is the instance of BABYLON.Scene to append to
  47650. * @param onSuccess a callback with the scene when import succeeds
  47651. * @param onProgress a callback with a progress event for each file being loaded
  47652. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47653. * @param pluginExtension the extension used to determine the plugin
  47654. * @returns The loaded plugin
  47655. */
  47656. 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>;
  47657. /**
  47658. * Append a scene
  47659. * @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)
  47660. * @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)
  47661. * @param scene is the instance of BABYLON.Scene to append to
  47662. * @param onProgress a callback with a progress event for each file being loaded
  47663. * @param pluginExtension the extension used to determine the plugin
  47664. * @returns The given scene
  47665. */
  47666. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47667. /**
  47668. * Load a scene into an asset container
  47669. * @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)
  47670. * @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)
  47671. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47672. * @param onSuccess a callback with the scene when import succeeds
  47673. * @param onProgress a callback with a progress event for each file being loaded
  47674. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47675. * @param pluginExtension the extension used to determine the plugin
  47676. * @returns The loaded plugin
  47677. */
  47678. 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>;
  47679. /**
  47680. * Load a scene into an asset container
  47681. * @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)
  47682. * @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)
  47683. * @param scene is the instance of Scene to append to
  47684. * @param onProgress a callback with a progress event for each file being loaded
  47685. * @param pluginExtension the extension used to determine the plugin
  47686. * @returns The loaded asset container
  47687. */
  47688. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47689. /**
  47690. * Import animations from a file into a scene
  47691. * @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)
  47692. * @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)
  47693. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47694. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47695. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47696. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47697. * @param onSuccess a callback with the scene when import succeeds
  47698. * @param onProgress a callback with a progress event for each file being loaded
  47699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47700. * @param pluginExtension the extension used to determine the plugin
  47701. */
  47702. 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;
  47703. /**
  47704. * Import animations from a file into a scene
  47705. * @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)
  47706. * @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)
  47707. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47708. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47709. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47710. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47711. * @param onSuccess a callback with the scene when import succeeds
  47712. * @param onProgress a callback with a progress event for each file being loaded
  47713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47714. * @param pluginExtension the extension used to determine the plugin
  47715. * @returns the updated scene with imported animations
  47716. */
  47717. 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>;
  47718. }
  47719. }
  47720. declare module BABYLON {
  47721. /**
  47722. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47723. */
  47724. export type MotionControllerHandedness = "none" | "left" | "right";
  47725. /**
  47726. * The type of components available in motion controllers.
  47727. * This is not the name of the component.
  47728. */
  47729. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47730. /**
  47731. * The state of a controller component
  47732. */
  47733. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47734. /**
  47735. * The schema of motion controller layout.
  47736. * No object will be initialized using this interface
  47737. * This is used just to define the profile.
  47738. */
  47739. export interface IMotionControllerLayout {
  47740. /**
  47741. * Path to load the assets. Usually relative to the base path
  47742. */
  47743. assetPath: string;
  47744. /**
  47745. * Available components (unsorted)
  47746. */
  47747. components: {
  47748. /**
  47749. * A map of component Ids
  47750. */
  47751. [componentId: string]: {
  47752. /**
  47753. * The type of input the component outputs
  47754. */
  47755. type: MotionControllerComponentType;
  47756. /**
  47757. * The indices of this component in the gamepad object
  47758. */
  47759. gamepadIndices: {
  47760. /**
  47761. * Index of button
  47762. */
  47763. button?: number;
  47764. /**
  47765. * If available, index of x-axis
  47766. */
  47767. xAxis?: number;
  47768. /**
  47769. * If available, index of y-axis
  47770. */
  47771. yAxis?: number;
  47772. };
  47773. /**
  47774. * The mesh's root node name
  47775. */
  47776. rootNodeName: string;
  47777. /**
  47778. * Animation definitions for this model
  47779. */
  47780. visualResponses: {
  47781. [stateKey: string]: {
  47782. /**
  47783. * What property will be animated
  47784. */
  47785. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47786. /**
  47787. * What states influence this visual response
  47788. */
  47789. states: MotionControllerComponentStateType[];
  47790. /**
  47791. * Type of animation - movement or visibility
  47792. */
  47793. valueNodeProperty: "transform" | "visibility";
  47794. /**
  47795. * Base node name to move. Its position will be calculated according to the min and max nodes
  47796. */
  47797. valueNodeName?: string;
  47798. /**
  47799. * Minimum movement node
  47800. */
  47801. minNodeName?: string;
  47802. /**
  47803. * Max movement node
  47804. */
  47805. maxNodeName?: string;
  47806. };
  47807. };
  47808. /**
  47809. * If touch enabled, what is the name of node to display user feedback
  47810. */
  47811. touchPointNodeName?: string;
  47812. };
  47813. };
  47814. /**
  47815. * Is it xr standard mapping or not
  47816. */
  47817. gamepadMapping: "" | "xr-standard";
  47818. /**
  47819. * Base root node of this entire model
  47820. */
  47821. rootNodeName: string;
  47822. /**
  47823. * Defines the main button component id
  47824. */
  47825. selectComponentId: string;
  47826. }
  47827. /**
  47828. * A definition for the layout map in the input profile
  47829. */
  47830. export interface IMotionControllerLayoutMap {
  47831. /**
  47832. * Layouts with handedness type as a key
  47833. */
  47834. [handedness: string]: IMotionControllerLayout;
  47835. }
  47836. /**
  47837. * The XR Input profile schema
  47838. * Profiles can be found here:
  47839. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47840. */
  47841. export interface IMotionControllerProfile {
  47842. /**
  47843. * fallback profiles for this profileId
  47844. */
  47845. fallbackProfileIds: string[];
  47846. /**
  47847. * The layout map, with handedness as key
  47848. */
  47849. layouts: IMotionControllerLayoutMap;
  47850. /**
  47851. * The id of this profile
  47852. * correlates to the profile(s) in the xrInput.profiles array
  47853. */
  47854. profileId: string;
  47855. }
  47856. /**
  47857. * A helper-interface for the 3 meshes needed for controller button animation
  47858. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47859. */
  47860. export interface IMotionControllerButtonMeshMap {
  47861. /**
  47862. * the mesh that defines the pressed value mesh position.
  47863. * This is used to find the max-position of this button
  47864. */
  47865. pressedMesh: AbstractMesh;
  47866. /**
  47867. * the mesh that defines the unpressed value mesh position.
  47868. * This is used to find the min (or initial) position of this button
  47869. */
  47870. unpressedMesh: AbstractMesh;
  47871. /**
  47872. * The mesh that will be changed when value changes
  47873. */
  47874. valueMesh: AbstractMesh;
  47875. }
  47876. /**
  47877. * A helper-interface for the 3 meshes needed for controller axis animation.
  47878. * This will be expanded when touchpad animations are fully supported
  47879. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47880. */
  47881. export interface IMotionControllerMeshMap {
  47882. /**
  47883. * the mesh that defines the maximum value mesh position.
  47884. */
  47885. maxMesh?: AbstractMesh;
  47886. /**
  47887. * the mesh that defines the minimum value mesh position.
  47888. */
  47889. minMesh?: AbstractMesh;
  47890. /**
  47891. * The mesh that will be changed when axis value changes
  47892. */
  47893. valueMesh: AbstractMesh;
  47894. }
  47895. /**
  47896. * The elements needed for change-detection of the gamepad objects in motion controllers
  47897. */
  47898. export interface IMinimalMotionControllerObject {
  47899. /**
  47900. * Available axes of this controller
  47901. */
  47902. axes: number[];
  47903. /**
  47904. * An array of available buttons
  47905. */
  47906. buttons: Array<{
  47907. /**
  47908. * Value of the button/trigger
  47909. */
  47910. value: number;
  47911. /**
  47912. * If the button/trigger is currently touched
  47913. */
  47914. touched: boolean;
  47915. /**
  47916. * If the button/trigger is currently pressed
  47917. */
  47918. pressed: boolean;
  47919. }>;
  47920. /**
  47921. * EXPERIMENTAL haptic support.
  47922. */
  47923. hapticActuators?: Array<{
  47924. pulse: (value: number, duration: number) => Promise<boolean>;
  47925. }>;
  47926. }
  47927. /**
  47928. * An Abstract Motion controller
  47929. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47930. * Each component has an observable to check for changes in value and state
  47931. */
  47932. export abstract class WebXRAbstractMotionController implements IDisposable {
  47933. protected scene: Scene;
  47934. protected layout: IMotionControllerLayout;
  47935. /**
  47936. * The gamepad object correlating to this controller
  47937. */
  47938. gamepadObject: IMinimalMotionControllerObject;
  47939. /**
  47940. * handedness (left/right/none) of this controller
  47941. */
  47942. handedness: MotionControllerHandedness;
  47943. private _initComponent;
  47944. private _modelReady;
  47945. /**
  47946. * A map of components (WebXRControllerComponent) in this motion controller
  47947. * Components have a ComponentType and can also have both button and axis definitions
  47948. */
  47949. readonly components: {
  47950. [id: string]: WebXRControllerComponent;
  47951. };
  47952. /**
  47953. * Disable the model's animation. Can be set at any time.
  47954. */
  47955. disableAnimation: boolean;
  47956. /**
  47957. * Observers registered here will be triggered when the model of this controller is done loading
  47958. */
  47959. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47960. /**
  47961. * The profile id of this motion controller
  47962. */
  47963. abstract profileId: string;
  47964. /**
  47965. * The root mesh of the model. It is null if the model was not yet initialized
  47966. */
  47967. rootMesh: Nullable<AbstractMesh>;
  47968. /**
  47969. * constructs a new abstract motion controller
  47970. * @param scene the scene to which the model of the controller will be added
  47971. * @param layout The profile layout to load
  47972. * @param gamepadObject The gamepad object correlating to this controller
  47973. * @param handedness handedness (left/right/none) of this controller
  47974. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47975. */
  47976. constructor(scene: Scene, layout: IMotionControllerLayout,
  47977. /**
  47978. * The gamepad object correlating to this controller
  47979. */
  47980. gamepadObject: IMinimalMotionControllerObject,
  47981. /**
  47982. * handedness (left/right/none) of this controller
  47983. */
  47984. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47985. /**
  47986. * Dispose this controller, the model mesh and all its components
  47987. */
  47988. dispose(): void;
  47989. /**
  47990. * Returns all components of specific type
  47991. * @param type the type to search for
  47992. * @return an array of components with this type
  47993. */
  47994. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47995. /**
  47996. * get a component based an its component id as defined in layout.components
  47997. * @param id the id of the component
  47998. * @returns the component correlates to the id or undefined if not found
  47999. */
  48000. getComponent(id: string): WebXRControllerComponent;
  48001. /**
  48002. * Get the list of components available in this motion controller
  48003. * @returns an array of strings correlating to available components
  48004. */
  48005. getComponentIds(): string[];
  48006. /**
  48007. * Get the first component of specific type
  48008. * @param type type of component to find
  48009. * @return a controller component or null if not found
  48010. */
  48011. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48012. /**
  48013. * Get the main (Select) component of this controller as defined in the layout
  48014. * @returns the main component of this controller
  48015. */
  48016. getMainComponent(): WebXRControllerComponent;
  48017. /**
  48018. * Loads the model correlating to this controller
  48019. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48020. * @returns A promise fulfilled with the result of the model loading
  48021. */
  48022. loadModel(): Promise<boolean>;
  48023. /**
  48024. * Update this model using the current XRFrame
  48025. * @param xrFrame the current xr frame to use and update the model
  48026. */
  48027. updateFromXRFrame(xrFrame: XRFrame): void;
  48028. /**
  48029. * Backwards compatibility due to a deeply-integrated typo
  48030. */
  48031. get handness(): XREye;
  48032. /**
  48033. * Pulse (vibrate) this controller
  48034. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48035. * Consecutive calls to this function will cancel the last pulse call
  48036. *
  48037. * @param value the strength of the pulse in 0.0...1.0 range
  48038. * @param duration Duration of the pulse in milliseconds
  48039. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48040. * @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
  48041. */
  48042. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48043. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48044. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48045. /**
  48046. * Moves the axis on the controller mesh based on its current state
  48047. * @param axis the index of the axis
  48048. * @param axisValue the value of the axis which determines the meshes new position
  48049. * @hidden
  48050. */
  48051. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48052. /**
  48053. * Update the model itself with the current frame data
  48054. * @param xrFrame the frame to use for updating the model mesh
  48055. */
  48056. protected updateModel(xrFrame: XRFrame): void;
  48057. /**
  48058. * Get the filename and path for this controller's model
  48059. * @returns a map of filename and path
  48060. */
  48061. protected abstract _getFilenameAndPath(): {
  48062. filename: string;
  48063. path: string;
  48064. };
  48065. /**
  48066. * This function is called before the mesh is loaded. It checks for loading constraints.
  48067. * For example, this function can check if the GLB loader is available
  48068. * If this function returns false, the generic controller will be loaded instead
  48069. * @returns Is the client ready to load the mesh
  48070. */
  48071. protected abstract _getModelLoadingConstraints(): boolean;
  48072. /**
  48073. * This function will be called after the model was successfully loaded and can be used
  48074. * for mesh transformations before it is available for the user
  48075. * @param meshes the loaded meshes
  48076. */
  48077. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48078. /**
  48079. * Set the root mesh for this controller. Important for the WebXR controller class
  48080. * @param meshes the loaded meshes
  48081. */
  48082. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48083. /**
  48084. * A function executed each frame that updates the mesh (if needed)
  48085. * @param xrFrame the current xrFrame
  48086. */
  48087. protected abstract _updateModel(xrFrame: XRFrame): void;
  48088. private _getGenericFilenameAndPath;
  48089. private _getGenericParentMesh;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * A generic trigger-only motion controller for WebXR
  48095. */
  48096. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48097. /**
  48098. * Static version of the profile id of this controller
  48099. */
  48100. static ProfileId: string;
  48101. profileId: string;
  48102. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48103. protected _getFilenameAndPath(): {
  48104. filename: string;
  48105. path: string;
  48106. };
  48107. protected _getModelLoadingConstraints(): boolean;
  48108. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48109. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48110. protected _updateModel(): void;
  48111. }
  48112. }
  48113. declare module BABYLON {
  48114. /**
  48115. * Class containing static functions to help procedurally build meshes
  48116. */
  48117. export class SphereBuilder {
  48118. /**
  48119. * Creates a sphere mesh
  48120. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48121. * * 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`)
  48122. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48123. * * 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
  48124. * * 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)
  48125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48126. * * 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
  48127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48128. * @param name defines the name of the mesh
  48129. * @param options defines the options used to create the mesh
  48130. * @param scene defines the hosting scene
  48131. * @returns the sphere mesh
  48132. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48133. */
  48134. static CreateSphere(name: string, options: {
  48135. segments?: number;
  48136. diameter?: number;
  48137. diameterX?: number;
  48138. diameterY?: number;
  48139. diameterZ?: number;
  48140. arc?: number;
  48141. slice?: number;
  48142. sideOrientation?: number;
  48143. frontUVs?: Vector4;
  48144. backUVs?: Vector4;
  48145. updatable?: boolean;
  48146. }, scene?: Nullable<Scene>): Mesh;
  48147. }
  48148. }
  48149. declare module BABYLON {
  48150. /**
  48151. * A profiled motion controller has its profile loaded from an online repository.
  48152. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48153. */
  48154. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48155. private _repositoryUrl;
  48156. private _buttonMeshMapping;
  48157. private _touchDots;
  48158. /**
  48159. * The profile ID of this controller. Will be populated when the controller initializes.
  48160. */
  48161. profileId: string;
  48162. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48163. dispose(): void;
  48164. protected _getFilenameAndPath(): {
  48165. filename: string;
  48166. path: string;
  48167. };
  48168. protected _getModelLoadingConstraints(): boolean;
  48169. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48170. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48171. protected _updateModel(_xrFrame: XRFrame): void;
  48172. }
  48173. }
  48174. declare module BABYLON {
  48175. /**
  48176. * A construction function type to create a new controller based on an xrInput object
  48177. */
  48178. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48179. /**
  48180. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48181. *
  48182. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48183. * it should be replaced with auto-loaded controllers.
  48184. *
  48185. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48186. */
  48187. export class WebXRMotionControllerManager {
  48188. private static _AvailableControllers;
  48189. private static _Fallbacks;
  48190. private static _ProfileLoadingPromises;
  48191. private static _ProfilesList;
  48192. /**
  48193. * The base URL of the online controller repository. Can be changed at any time.
  48194. */
  48195. static BaseRepositoryUrl: string;
  48196. /**
  48197. * Which repository gets priority - local or online
  48198. */
  48199. static PrioritizeOnlineRepository: boolean;
  48200. /**
  48201. * Use the online repository, or use only locally-defined controllers
  48202. */
  48203. static UseOnlineRepository: boolean;
  48204. /**
  48205. * Clear the cache used for profile loading and reload when requested again
  48206. */
  48207. static ClearProfilesCache(): void;
  48208. /**
  48209. * Register the default fallbacks.
  48210. * This function is called automatically when this file is imported.
  48211. */
  48212. static DefaultFallbacks(): void;
  48213. /**
  48214. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48215. * @param profileId the profile to which a fallback needs to be found
  48216. * @return an array with corresponding fallback profiles
  48217. */
  48218. static FindFallbackWithProfileId(profileId: string): string[];
  48219. /**
  48220. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48221. * The order of search:
  48222. *
  48223. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48224. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48225. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48226. * 4) return the generic trigger controller if none were found
  48227. *
  48228. * @param xrInput the xrInput to which a new controller is initialized
  48229. * @param scene the scene to which the model will be added
  48230. * @param forceProfile force a certain profile for this controller
  48231. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48232. */
  48233. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48234. /**
  48235. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48236. *
  48237. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48238. *
  48239. * @param type the profile type to register
  48240. * @param constructFunction the function to be called when loading this profile
  48241. */
  48242. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48243. /**
  48244. * Register a fallback to a specific profile.
  48245. * @param profileId the profileId that will receive the fallbacks
  48246. * @param fallbacks A list of fallback profiles
  48247. */
  48248. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48249. /**
  48250. * Will update the list of profiles available in the repository
  48251. * @return a promise that resolves to a map of profiles available online
  48252. */
  48253. static UpdateProfilesList(): Promise<{
  48254. [profile: string]: string;
  48255. }>;
  48256. private static _LoadProfileFromRepository;
  48257. private static _LoadProfilesFromAvailableControllers;
  48258. }
  48259. }
  48260. declare module BABYLON {
  48261. /**
  48262. * Configuration options for the WebXR controller creation
  48263. */
  48264. export interface IWebXRControllerOptions {
  48265. /**
  48266. * Should the controller mesh be animated when a user interacts with it
  48267. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48268. */
  48269. disableMotionControllerAnimation?: boolean;
  48270. /**
  48271. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48272. */
  48273. doNotLoadControllerMesh?: boolean;
  48274. /**
  48275. * Force a specific controller type for this controller.
  48276. * This can be used when creating your own profile or when testing different controllers
  48277. */
  48278. forceControllerProfile?: string;
  48279. /**
  48280. * Defines a rendering group ID for meshes that will be loaded.
  48281. * This is for the default controllers only.
  48282. */
  48283. renderingGroupId?: number;
  48284. }
  48285. /**
  48286. * Represents an XR controller
  48287. */
  48288. export class WebXRInputSource {
  48289. private _scene;
  48290. /** The underlying input source for the controller */
  48291. inputSource: XRInputSource;
  48292. private _options;
  48293. private _tmpVector;
  48294. private _uniqueId;
  48295. /**
  48296. * 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
  48297. */
  48298. grip?: AbstractMesh;
  48299. /**
  48300. * If available, this is the gamepad object related to this controller.
  48301. * Using this object it is possible to get click events and trackpad changes of the
  48302. * webxr controller that is currently being used.
  48303. */
  48304. motionController?: WebXRAbstractMotionController;
  48305. /**
  48306. * Event that fires when the controller is removed/disposed.
  48307. * The object provided as event data is this controller, after associated assets were disposed.
  48308. * uniqueId is still available.
  48309. */
  48310. onDisposeObservable: Observable<WebXRInputSource>;
  48311. /**
  48312. * Will be triggered when the mesh associated with the motion controller is done loading.
  48313. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48314. * A shortened version of controller -> motion controller -> on mesh loaded.
  48315. */
  48316. onMeshLoadedObservable: Observable<AbstractMesh>;
  48317. /**
  48318. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48319. */
  48320. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48321. /**
  48322. * Pointer which can be used to select objects or attach a visible laser to
  48323. */
  48324. pointer: AbstractMesh;
  48325. /**
  48326. * Creates the input source object
  48327. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48328. * @param _scene the scene which the controller should be associated to
  48329. * @param inputSource the underlying input source for the controller
  48330. * @param _options options for this controller creation
  48331. */
  48332. constructor(_scene: Scene,
  48333. /** The underlying input source for the controller */
  48334. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48335. /**
  48336. * Get this controllers unique id
  48337. */
  48338. get uniqueId(): string;
  48339. /**
  48340. * Disposes of the object
  48341. */
  48342. dispose(): void;
  48343. /**
  48344. * Gets a world space ray coming from the pointer or grip
  48345. * @param result the resulting ray
  48346. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48347. */
  48348. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48349. /**
  48350. * Updates the controller pose based on the given XRFrame
  48351. * @param xrFrame xr frame to update the pose with
  48352. * @param referenceSpace reference space to use
  48353. */
  48354. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48355. }
  48356. }
  48357. declare module BABYLON {
  48358. /**
  48359. * The schema for initialization options of the XR Input class
  48360. */
  48361. export interface IWebXRInputOptions {
  48362. /**
  48363. * If set to true no model will be automatically loaded
  48364. */
  48365. doNotLoadControllerMeshes?: boolean;
  48366. /**
  48367. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48368. * If not found, the xr input profile data will be used.
  48369. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48370. */
  48371. forceInputProfile?: string;
  48372. /**
  48373. * Do not send a request to the controller repository to load the profile.
  48374. *
  48375. * Instead, use the controllers available in babylon itself.
  48376. */
  48377. disableOnlineControllerRepository?: boolean;
  48378. /**
  48379. * A custom URL for the controllers repository
  48380. */
  48381. customControllersRepositoryURL?: string;
  48382. /**
  48383. * Should the controller model's components not move according to the user input
  48384. */
  48385. disableControllerAnimation?: boolean;
  48386. /**
  48387. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48388. */
  48389. controllerOptions?: IWebXRControllerOptions;
  48390. }
  48391. /**
  48392. * XR input used to track XR inputs such as controllers/rays
  48393. */
  48394. export class WebXRInput implements IDisposable {
  48395. /**
  48396. * the xr session manager for this session
  48397. */
  48398. xrSessionManager: WebXRSessionManager;
  48399. /**
  48400. * the WebXR camera for this session. Mainly used for teleportation
  48401. */
  48402. xrCamera: WebXRCamera;
  48403. private readonly options;
  48404. /**
  48405. * XR controllers being tracked
  48406. */
  48407. controllers: Array<WebXRInputSource>;
  48408. private _frameObserver;
  48409. private _sessionEndedObserver;
  48410. private _sessionInitObserver;
  48411. /**
  48412. * Event when a controller has been connected/added
  48413. */
  48414. onControllerAddedObservable: Observable<WebXRInputSource>;
  48415. /**
  48416. * Event when a controller has been removed/disconnected
  48417. */
  48418. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48419. /**
  48420. * Initializes the WebXRInput
  48421. * @param xrSessionManager the xr session manager for this session
  48422. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48423. * @param options = initialization options for this xr input
  48424. */
  48425. constructor(
  48426. /**
  48427. * the xr session manager for this session
  48428. */
  48429. xrSessionManager: WebXRSessionManager,
  48430. /**
  48431. * the WebXR camera for this session. Mainly used for teleportation
  48432. */
  48433. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48434. private _onInputSourcesChange;
  48435. private _addAndRemoveControllers;
  48436. /**
  48437. * Disposes of the object
  48438. */
  48439. dispose(): void;
  48440. }
  48441. }
  48442. declare module BABYLON {
  48443. /**
  48444. * This is the base class for all WebXR features.
  48445. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48446. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48447. */
  48448. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48449. protected _xrSessionManager: WebXRSessionManager;
  48450. private _attached;
  48451. private _removeOnDetach;
  48452. /**
  48453. * Should auto-attach be disabled?
  48454. */
  48455. disableAutoAttach: boolean;
  48456. /**
  48457. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48458. */
  48459. xrNativeFeatureName: string;
  48460. /**
  48461. * Construct a new (abstract) WebXR feature
  48462. * @param _xrSessionManager the xr session manager for this feature
  48463. */
  48464. constructor(_xrSessionManager: WebXRSessionManager);
  48465. /**
  48466. * Is this feature attached
  48467. */
  48468. get attached(): boolean;
  48469. /**
  48470. * attach this feature
  48471. *
  48472. * @param force should attachment be forced (even when already attached)
  48473. * @returns true if successful, false is failed or already attached
  48474. */
  48475. attach(force?: boolean): boolean;
  48476. /**
  48477. * detach this feature.
  48478. *
  48479. * @returns true if successful, false if failed or already detached
  48480. */
  48481. detach(): boolean;
  48482. /**
  48483. * Dispose this feature and all of the resources attached
  48484. */
  48485. dispose(): void;
  48486. /**
  48487. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48488. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48489. *
  48490. * @returns whether or not the feature is compatible in this environment
  48491. */
  48492. isCompatible(): boolean;
  48493. /**
  48494. * This is used to register callbacks that will automatically be removed when detach is called.
  48495. * @param observable the observable to which the observer will be attached
  48496. * @param callback the callback to register
  48497. */
  48498. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48499. /**
  48500. * Code in this function will be executed on each xrFrame received from the browser.
  48501. * This function will not execute after the feature is detached.
  48502. * @param _xrFrame the current frame
  48503. */
  48504. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48505. }
  48506. }
  48507. declare module BABYLON {
  48508. /**
  48509. * Renders a layer on top of an existing scene
  48510. */
  48511. export class UtilityLayerRenderer implements IDisposable {
  48512. /** the original scene that will be rendered on top of */
  48513. originalScene: Scene;
  48514. private _pointerCaptures;
  48515. private _lastPointerEvents;
  48516. private static _DefaultUtilityLayer;
  48517. private static _DefaultKeepDepthUtilityLayer;
  48518. private _sharedGizmoLight;
  48519. private _renderCamera;
  48520. /**
  48521. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48522. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48523. * @returns the camera that is used when rendering the utility layer
  48524. */
  48525. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48526. /**
  48527. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48528. * @param cam the camera that should be used when rendering the utility layer
  48529. */
  48530. setRenderCamera(cam: Nullable<Camera>): void;
  48531. /**
  48532. * @hidden
  48533. * Light which used by gizmos to get light shading
  48534. */
  48535. _getSharedGizmoLight(): HemisphericLight;
  48536. /**
  48537. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48538. */
  48539. pickUtilitySceneFirst: boolean;
  48540. /**
  48541. * 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)
  48542. */
  48543. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48544. /**
  48545. * 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)
  48546. */
  48547. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48548. /**
  48549. * The scene that is rendered on top of the original scene
  48550. */
  48551. utilityLayerScene: Scene;
  48552. /**
  48553. * If the utility layer should automatically be rendered on top of existing scene
  48554. */
  48555. shouldRender: boolean;
  48556. /**
  48557. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48558. */
  48559. onlyCheckPointerDownEvents: boolean;
  48560. /**
  48561. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48562. */
  48563. processAllEvents: boolean;
  48564. /**
  48565. * Observable raised when the pointer move from the utility layer scene to the main scene
  48566. */
  48567. onPointerOutObservable: Observable<number>;
  48568. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48569. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48570. private _afterRenderObserver;
  48571. private _sceneDisposeObserver;
  48572. private _originalPointerObserver;
  48573. /**
  48574. * Instantiates a UtilityLayerRenderer
  48575. * @param originalScene the original scene that will be rendered on top of
  48576. * @param handleEvents boolean indicating if the utility layer should handle events
  48577. */
  48578. constructor(
  48579. /** the original scene that will be rendered on top of */
  48580. originalScene: Scene, handleEvents?: boolean);
  48581. private _notifyObservers;
  48582. /**
  48583. * Renders the utility layers scene on top of the original scene
  48584. */
  48585. render(): void;
  48586. /**
  48587. * Disposes of the renderer
  48588. */
  48589. dispose(): void;
  48590. private _updateCamera;
  48591. }
  48592. }
  48593. declare module BABYLON {
  48594. /**
  48595. * Options interface for the pointer selection module
  48596. */
  48597. export interface IWebXRControllerPointerSelectionOptions {
  48598. /**
  48599. * if provided, this scene will be used to render meshes.
  48600. */
  48601. customUtilityLayerScene?: Scene;
  48602. /**
  48603. * 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)
  48604. * If not disabled, the last picked point will be used to execute a pointer up event
  48605. * If disabled, pointer up event will be triggered right after the pointer down event.
  48606. * Used in screen and gaze target ray mode only
  48607. */
  48608. disablePointerUpOnTouchOut: boolean;
  48609. /**
  48610. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48611. */
  48612. forceGazeMode: boolean;
  48613. /**
  48614. * 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
  48615. * to start a new countdown to the pointer down event.
  48616. * Defaults to 1.
  48617. */
  48618. gazeModePointerMovedFactor?: number;
  48619. /**
  48620. * Different button type to use instead of the main component
  48621. */
  48622. overrideButtonId?: string;
  48623. /**
  48624. * use this rendering group id for the meshes (optional)
  48625. */
  48626. renderingGroupId?: number;
  48627. /**
  48628. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48629. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48630. * 3000 means 3 seconds between pointing at something and selecting it
  48631. */
  48632. timeToSelect?: number;
  48633. /**
  48634. * Should meshes created here be added to a utility layer or the main scene
  48635. */
  48636. useUtilityLayer?: boolean;
  48637. /**
  48638. * Optional WebXR camera to be used for gaze selection
  48639. */
  48640. gazeCamera?: WebXRCamera;
  48641. /**
  48642. * the xr input to use with this pointer selection
  48643. */
  48644. xrInput: WebXRInput;
  48645. }
  48646. /**
  48647. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48648. */
  48649. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48650. private readonly _options;
  48651. private static _idCounter;
  48652. private _attachController;
  48653. private _controllers;
  48654. private _scene;
  48655. private _tmpVectorForPickCompare;
  48656. /**
  48657. * The module's name
  48658. */
  48659. static readonly Name: string;
  48660. /**
  48661. * The (Babylon) version of this module.
  48662. * This is an integer representing the implementation version.
  48663. * This number does not correspond to the WebXR specs version
  48664. */
  48665. static readonly Version: number;
  48666. /**
  48667. * Disable lighting on the laser pointer (so it will always be visible)
  48668. */
  48669. disablePointerLighting: boolean;
  48670. /**
  48671. * Disable lighting on the selection mesh (so it will always be visible)
  48672. */
  48673. disableSelectionMeshLighting: boolean;
  48674. /**
  48675. * Should the laser pointer be displayed
  48676. */
  48677. displayLaserPointer: boolean;
  48678. /**
  48679. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48680. */
  48681. displaySelectionMesh: boolean;
  48682. /**
  48683. * This color will be set to the laser pointer when selection is triggered
  48684. */
  48685. laserPointerPickedColor: Color3;
  48686. /**
  48687. * Default color of the laser pointer
  48688. */
  48689. laserPointerDefaultColor: Color3;
  48690. /**
  48691. * default color of the selection ring
  48692. */
  48693. selectionMeshDefaultColor: Color3;
  48694. /**
  48695. * This color will be applied to the selection ring when selection is triggered
  48696. */
  48697. selectionMeshPickedColor: Color3;
  48698. /**
  48699. * Optional filter to be used for ray selection. This predicate shares behavior with
  48700. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48701. */
  48702. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48703. /**
  48704. * constructs a new background remover module
  48705. * @param _xrSessionManager the session manager for this module
  48706. * @param _options read-only options to be used in this module
  48707. */
  48708. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48709. /**
  48710. * attach this feature
  48711. * Will usually be called by the features manager
  48712. *
  48713. * @returns true if successful.
  48714. */
  48715. attach(): boolean;
  48716. /**
  48717. * detach this feature.
  48718. * Will usually be called by the features manager
  48719. *
  48720. * @returns true if successful.
  48721. */
  48722. detach(): boolean;
  48723. /**
  48724. * Will get the mesh under a specific pointer.
  48725. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48726. * @param controllerId the controllerId to check
  48727. * @returns The mesh under pointer or null if no mesh is under the pointer
  48728. */
  48729. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48730. /**
  48731. * Get the xr controller that correlates to the pointer id in the pointer event
  48732. *
  48733. * @param id the pointer id to search for
  48734. * @returns the controller that correlates to this id or null if not found
  48735. */
  48736. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48737. protected _onXRFrame(_xrFrame: XRFrame): void;
  48738. private _attachGazeMode;
  48739. private _attachScreenRayMode;
  48740. private _attachTrackedPointerRayMode;
  48741. private _convertNormalToDirectionOfRay;
  48742. private _detachController;
  48743. private _generateNewMeshPair;
  48744. private _pickingMoved;
  48745. private _updatePointerDistance;
  48746. /** @hidden */
  48747. get lasterPointerDefaultColor(): Color3;
  48748. }
  48749. }
  48750. declare module BABYLON {
  48751. /**
  48752. * Button which can be used to enter a different mode of XR
  48753. */
  48754. export class WebXREnterExitUIButton {
  48755. /** button element */
  48756. element: HTMLElement;
  48757. /** XR initialization options for the button */
  48758. sessionMode: XRSessionMode;
  48759. /** Reference space type */
  48760. referenceSpaceType: XRReferenceSpaceType;
  48761. /**
  48762. * Creates a WebXREnterExitUIButton
  48763. * @param element button element
  48764. * @param sessionMode XR initialization session mode
  48765. * @param referenceSpaceType the type of reference space to be used
  48766. */
  48767. constructor(
  48768. /** button element */
  48769. element: HTMLElement,
  48770. /** XR initialization options for the button */
  48771. sessionMode: XRSessionMode,
  48772. /** Reference space type */
  48773. referenceSpaceType: XRReferenceSpaceType);
  48774. /**
  48775. * Extendable function which can be used to update the button's visuals when the state changes
  48776. * @param activeButton the current active button in the UI
  48777. */
  48778. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48779. }
  48780. /**
  48781. * Options to create the webXR UI
  48782. */
  48783. export class WebXREnterExitUIOptions {
  48784. /**
  48785. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48786. */
  48787. customButtons?: Array<WebXREnterExitUIButton>;
  48788. /**
  48789. * A reference space type to use when creating the default button.
  48790. * Default is local-floor
  48791. */
  48792. referenceSpaceType?: XRReferenceSpaceType;
  48793. /**
  48794. * Context to enter xr with
  48795. */
  48796. renderTarget?: Nullable<WebXRRenderTarget>;
  48797. /**
  48798. * A session mode to use when creating the default button.
  48799. * Default is immersive-vr
  48800. */
  48801. sessionMode?: XRSessionMode;
  48802. /**
  48803. * A list of optional features to init the session with
  48804. */
  48805. optionalFeatures?: string[];
  48806. /**
  48807. * A list of optional features to init the session with
  48808. */
  48809. requiredFeatures?: string[];
  48810. }
  48811. /**
  48812. * UI to allow the user to enter/exit XR mode
  48813. */
  48814. export class WebXREnterExitUI implements IDisposable {
  48815. private scene;
  48816. /** version of the options passed to this UI */
  48817. options: WebXREnterExitUIOptions;
  48818. private _activeButton;
  48819. private _buttons;
  48820. private _overlay;
  48821. /**
  48822. * Fired every time the active button is changed.
  48823. *
  48824. * When xr is entered via a button that launches xr that button will be the callback parameter
  48825. *
  48826. * When exiting xr the callback parameter will be null)
  48827. */
  48828. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48829. /**
  48830. *
  48831. * @param scene babylon scene object to use
  48832. * @param options (read-only) version of the options passed to this UI
  48833. */
  48834. private constructor();
  48835. /**
  48836. * Creates UI to allow the user to enter/exit XR mode
  48837. * @param scene the scene to add the ui to
  48838. * @param helper the xr experience helper to enter/exit xr with
  48839. * @param options options to configure the UI
  48840. * @returns the created ui
  48841. */
  48842. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48843. /**
  48844. * Disposes of the XR UI component
  48845. */
  48846. dispose(): void;
  48847. private _updateButtons;
  48848. }
  48849. }
  48850. declare module BABYLON {
  48851. /**
  48852. * Class containing static functions to help procedurally build meshes
  48853. */
  48854. export class LinesBuilder {
  48855. /**
  48856. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48857. * * 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
  48858. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48859. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48860. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48861. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48862. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48863. * * 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
  48864. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48867. * @param name defines the name of the new line system
  48868. * @param options defines the options used to create the line system
  48869. * @param scene defines the hosting scene
  48870. * @returns a new line system mesh
  48871. */
  48872. static CreateLineSystem(name: string, options: {
  48873. lines: Vector3[][];
  48874. updatable?: boolean;
  48875. instance?: Nullable<LinesMesh>;
  48876. colors?: Nullable<Color4[][]>;
  48877. useVertexAlpha?: boolean;
  48878. }, scene: Nullable<Scene>): LinesMesh;
  48879. /**
  48880. * Creates a line mesh
  48881. * 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
  48882. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48883. * * The parameter `points` is an array successive Vector3
  48884. * * 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
  48885. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48886. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48887. * * When updating an instance, remember that only point positions can change, not the number of points
  48888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48890. * @param name defines the name of the new line system
  48891. * @param options defines the options used to create the line system
  48892. * @param scene defines the hosting scene
  48893. * @returns a new line mesh
  48894. */
  48895. static CreateLines(name: string, options: {
  48896. points: Vector3[];
  48897. updatable?: boolean;
  48898. instance?: Nullable<LinesMesh>;
  48899. colors?: Color4[];
  48900. useVertexAlpha?: boolean;
  48901. }, scene?: Nullable<Scene>): LinesMesh;
  48902. /**
  48903. * Creates a dashed line mesh
  48904. * * 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
  48905. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48906. * * The parameter `points` is an array successive Vector3
  48907. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48908. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48909. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48910. * * 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
  48911. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48912. * * When updating an instance, remember that only point positions can change, not the number of points
  48913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48914. * @param name defines the name of the mesh
  48915. * @param options defines the options used to create the mesh
  48916. * @param scene defines the hosting scene
  48917. * @returns the dashed line mesh
  48918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48919. */
  48920. static CreateDashedLines(name: string, options: {
  48921. points: Vector3[];
  48922. dashSize?: number;
  48923. gapSize?: number;
  48924. dashNb?: number;
  48925. updatable?: boolean;
  48926. instance?: LinesMesh;
  48927. useVertexAlpha?: boolean;
  48928. }, scene?: Nullable<Scene>): LinesMesh;
  48929. }
  48930. }
  48931. declare module BABYLON {
  48932. /**
  48933. * Construction options for a timer
  48934. */
  48935. export interface ITimerOptions<T> {
  48936. /**
  48937. * Time-to-end
  48938. */
  48939. timeout: number;
  48940. /**
  48941. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48942. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48943. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48944. */
  48945. contextObservable: Observable<T>;
  48946. /**
  48947. * Optional parameters when adding an observer to the observable
  48948. */
  48949. observableParameters?: {
  48950. mask?: number;
  48951. insertFirst?: boolean;
  48952. scope?: any;
  48953. };
  48954. /**
  48955. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48956. */
  48957. breakCondition?: (data?: ITimerData<T>) => boolean;
  48958. /**
  48959. * Will be triggered when the time condition has met
  48960. */
  48961. onEnded?: (data: ITimerData<any>) => void;
  48962. /**
  48963. * Will be triggered when the break condition has met (prematurely ended)
  48964. */
  48965. onAborted?: (data: ITimerData<any>) => void;
  48966. /**
  48967. * Optional function to execute on each tick (or count)
  48968. */
  48969. onTick?: (data: ITimerData<any>) => void;
  48970. }
  48971. /**
  48972. * An interface defining the data sent by the timer
  48973. */
  48974. export interface ITimerData<T> {
  48975. /**
  48976. * When did it start
  48977. */
  48978. startTime: number;
  48979. /**
  48980. * Time now
  48981. */
  48982. currentTime: number;
  48983. /**
  48984. * Time passed since started
  48985. */
  48986. deltaTime: number;
  48987. /**
  48988. * How much is completed, in [0.0...1.0].
  48989. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48990. */
  48991. completeRate: number;
  48992. /**
  48993. * What the registered observable sent in the last count
  48994. */
  48995. payload: T;
  48996. }
  48997. /**
  48998. * The current state of the timer
  48999. */
  49000. export enum TimerState {
  49001. /**
  49002. * Timer initialized, not yet started
  49003. */
  49004. INIT = 0,
  49005. /**
  49006. * Timer started and counting
  49007. */
  49008. STARTED = 1,
  49009. /**
  49010. * Timer ended (whether aborted or time reached)
  49011. */
  49012. ENDED = 2
  49013. }
  49014. /**
  49015. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49016. *
  49017. * @param options options with which to initialize this timer
  49018. */
  49019. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49020. /**
  49021. * An advanced implementation of a timer class
  49022. */
  49023. export class AdvancedTimer<T = any> implements IDisposable {
  49024. /**
  49025. * Will notify each time the timer calculates the remaining time
  49026. */
  49027. onEachCountObservable: Observable<ITimerData<T>>;
  49028. /**
  49029. * Will trigger when the timer was aborted due to the break condition
  49030. */
  49031. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49032. /**
  49033. * Will trigger when the timer ended successfully
  49034. */
  49035. onTimerEndedObservable: Observable<ITimerData<T>>;
  49036. /**
  49037. * Will trigger when the timer state has changed
  49038. */
  49039. onStateChangedObservable: Observable<TimerState>;
  49040. private _observer;
  49041. private _contextObservable;
  49042. private _observableParameters;
  49043. private _startTime;
  49044. private _timer;
  49045. private _state;
  49046. private _breakCondition;
  49047. private _timeToEnd;
  49048. private _breakOnNextTick;
  49049. /**
  49050. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49051. * @param options construction options for this advanced timer
  49052. */
  49053. constructor(options: ITimerOptions<T>);
  49054. /**
  49055. * set a breaking condition for this timer. Default is to never break during count
  49056. * @param predicate the new break condition. Returns true to break, false otherwise
  49057. */
  49058. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49059. /**
  49060. * Reset ALL associated observables in this advanced timer
  49061. */
  49062. clearObservables(): void;
  49063. /**
  49064. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49065. *
  49066. * @param timeToEnd how much time to measure until timer ended
  49067. */
  49068. start(timeToEnd?: number): void;
  49069. /**
  49070. * Will force a stop on the next tick.
  49071. */
  49072. stop(): void;
  49073. /**
  49074. * Dispose this timer, clearing all resources
  49075. */
  49076. dispose(): void;
  49077. private _setState;
  49078. private _tick;
  49079. private _stop;
  49080. }
  49081. }
  49082. declare module BABYLON {
  49083. /**
  49084. * The options container for the teleportation module
  49085. */
  49086. export interface IWebXRTeleportationOptions {
  49087. /**
  49088. * if provided, this scene will be used to render meshes.
  49089. */
  49090. customUtilityLayerScene?: Scene;
  49091. /**
  49092. * Values to configure the default target mesh
  49093. */
  49094. defaultTargetMeshOptions?: {
  49095. /**
  49096. * Fill color of the teleportation area
  49097. */
  49098. teleportationFillColor?: string;
  49099. /**
  49100. * Border color for the teleportation area
  49101. */
  49102. teleportationBorderColor?: string;
  49103. /**
  49104. * Disable the mesh's animation sequence
  49105. */
  49106. disableAnimation?: boolean;
  49107. /**
  49108. * Disable lighting on the material or the ring and arrow
  49109. */
  49110. disableLighting?: boolean;
  49111. /**
  49112. * Override the default material of the torus and arrow
  49113. */
  49114. torusArrowMaterial?: Material;
  49115. };
  49116. /**
  49117. * A list of meshes to use as floor meshes.
  49118. * Meshes can be added and removed after initializing the feature using the
  49119. * addFloorMesh and removeFloorMesh functions
  49120. * If empty, rotation will still work
  49121. */
  49122. floorMeshes?: AbstractMesh[];
  49123. /**
  49124. * use this rendering group id for the meshes (optional)
  49125. */
  49126. renderingGroupId?: number;
  49127. /**
  49128. * Should teleportation move only to snap points
  49129. */
  49130. snapPointsOnly?: boolean;
  49131. /**
  49132. * An array of points to which the teleportation will snap to.
  49133. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49134. */
  49135. snapPositions?: Vector3[];
  49136. /**
  49137. * How close should the teleportation ray be in order to snap to position.
  49138. * Default to 0.8 units (meters)
  49139. */
  49140. snapToPositionRadius?: number;
  49141. /**
  49142. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49143. * If you want to support rotation, make sure your mesh has a direction indicator.
  49144. *
  49145. * When left untouched, the default mesh will be initialized.
  49146. */
  49147. teleportationTargetMesh?: AbstractMesh;
  49148. /**
  49149. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49150. */
  49151. timeToTeleport?: number;
  49152. /**
  49153. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49154. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49155. */
  49156. useMainComponentOnly?: boolean;
  49157. /**
  49158. * Should meshes created here be added to a utility layer or the main scene
  49159. */
  49160. useUtilityLayer?: boolean;
  49161. /**
  49162. * Babylon XR Input class for controller
  49163. */
  49164. xrInput: WebXRInput;
  49165. }
  49166. /**
  49167. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49168. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49169. * the input of the attached controllers.
  49170. */
  49171. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49172. private _options;
  49173. private _controllers;
  49174. private _currentTeleportationControllerId;
  49175. private _floorMeshes;
  49176. private _quadraticBezierCurve;
  49177. private _selectionFeature;
  49178. private _snapToPositions;
  49179. private _snappedToPoint;
  49180. private _teleportationRingMaterial?;
  49181. private _tmpRay;
  49182. private _tmpVector;
  49183. /**
  49184. * The module's name
  49185. */
  49186. static readonly Name: string;
  49187. /**
  49188. * The (Babylon) version of this module.
  49189. * This is an integer representing the implementation version.
  49190. * This number does not correspond to the webxr specs version
  49191. */
  49192. static readonly Version: number;
  49193. /**
  49194. * Is movement backwards enabled
  49195. */
  49196. backwardsMovementEnabled: boolean;
  49197. /**
  49198. * Distance to travel when moving backwards
  49199. */
  49200. backwardsTeleportationDistance: number;
  49201. /**
  49202. * The distance from the user to the inspection point in the direction of the controller
  49203. * A higher number will allow the user to move further
  49204. * defaults to 5 (meters, in xr units)
  49205. */
  49206. parabolicCheckRadius: number;
  49207. /**
  49208. * Should the module support parabolic ray on top of direct ray
  49209. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49210. * Very helpful when moving between floors / different heights
  49211. */
  49212. parabolicRayEnabled: boolean;
  49213. /**
  49214. * How much rotation should be applied when rotating right and left
  49215. */
  49216. rotationAngle: number;
  49217. /**
  49218. * Is rotation enabled when moving forward?
  49219. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49220. */
  49221. rotationEnabled: boolean;
  49222. /**
  49223. * constructs a new anchor system
  49224. * @param _xrSessionManager an instance of WebXRSessionManager
  49225. * @param _options configuration object for this feature
  49226. */
  49227. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49228. /**
  49229. * Get the snapPointsOnly flag
  49230. */
  49231. get snapPointsOnly(): boolean;
  49232. /**
  49233. * Sets the snapPointsOnly flag
  49234. * @param snapToPoints should teleportation be exclusively to snap points
  49235. */
  49236. set snapPointsOnly(snapToPoints: boolean);
  49237. /**
  49238. * Add a new mesh to the floor meshes array
  49239. * @param mesh the mesh to use as floor mesh
  49240. */
  49241. addFloorMesh(mesh: AbstractMesh): void;
  49242. /**
  49243. * Add a new snap-to point to fix teleportation to this position
  49244. * @param newSnapPoint The new Snap-To point
  49245. */
  49246. addSnapPoint(newSnapPoint: Vector3): void;
  49247. attach(): boolean;
  49248. detach(): boolean;
  49249. dispose(): void;
  49250. /**
  49251. * Remove a mesh from the floor meshes array
  49252. * @param mesh the mesh to remove
  49253. */
  49254. removeFloorMesh(mesh: AbstractMesh): void;
  49255. /**
  49256. * Remove a mesh from the floor meshes array using its name
  49257. * @param name the mesh name to remove
  49258. */
  49259. removeFloorMeshByName(name: string): void;
  49260. /**
  49261. * 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
  49262. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49263. * @returns was the point found and removed or not
  49264. */
  49265. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49266. /**
  49267. * This function sets a selection feature that will be disabled when
  49268. * the forward ray is shown and will be reattached when hidden.
  49269. * This is used to remove the selection rays when moving.
  49270. * @param selectionFeature the feature to disable when forward movement is enabled
  49271. */
  49272. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49273. protected _onXRFrame(_xrFrame: XRFrame): void;
  49274. private _attachController;
  49275. private _createDefaultTargetMesh;
  49276. private _detachController;
  49277. private _findClosestSnapPointWithRadius;
  49278. private _setTargetMeshPosition;
  49279. private _setTargetMeshVisibility;
  49280. private _showParabolicPath;
  49281. private _teleportForward;
  49282. }
  49283. }
  49284. declare module BABYLON {
  49285. /**
  49286. * Options for the default xr helper
  49287. */
  49288. export class WebXRDefaultExperienceOptions {
  49289. /**
  49290. * Enable or disable default UI to enter XR
  49291. */
  49292. disableDefaultUI?: boolean;
  49293. /**
  49294. * Should teleportation not initialize. defaults to false.
  49295. */
  49296. disableTeleportation?: boolean;
  49297. /**
  49298. * Floor meshes that will be used for teleport
  49299. */
  49300. floorMeshes?: Array<AbstractMesh>;
  49301. /**
  49302. * If set to true, the first frame will not be used to reset position
  49303. * The first frame is mainly used when copying transformation from the old camera
  49304. * Mainly used in AR
  49305. */
  49306. ignoreNativeCameraTransformation?: boolean;
  49307. /**
  49308. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49309. */
  49310. inputOptions?: IWebXRInputOptions;
  49311. /**
  49312. * optional configuration for the output canvas
  49313. */
  49314. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49315. /**
  49316. * optional UI options. This can be used among other to change session mode and reference space type
  49317. */
  49318. uiOptions?: WebXREnterExitUIOptions;
  49319. /**
  49320. * When loading teleportation and pointer select, use stable versions instead of latest.
  49321. */
  49322. useStablePlugins?: boolean;
  49323. /**
  49324. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49325. */
  49326. renderingGroupId?: number;
  49327. /**
  49328. * A list of optional features to init the session with
  49329. * If set to true, all features we support will be added
  49330. */
  49331. optionalFeatures?: boolean | string[];
  49332. }
  49333. /**
  49334. * Default experience which provides a similar setup to the previous webVRExperience
  49335. */
  49336. export class WebXRDefaultExperience {
  49337. /**
  49338. * Base experience
  49339. */
  49340. baseExperience: WebXRExperienceHelper;
  49341. /**
  49342. * Enables ui for entering/exiting xr
  49343. */
  49344. enterExitUI: WebXREnterExitUI;
  49345. /**
  49346. * Input experience extension
  49347. */
  49348. input: WebXRInput;
  49349. /**
  49350. * Enables laser pointer and selection
  49351. */
  49352. pointerSelection: WebXRControllerPointerSelection;
  49353. /**
  49354. * Default target xr should render to
  49355. */
  49356. renderTarget: WebXRRenderTarget;
  49357. /**
  49358. * Enables teleportation
  49359. */
  49360. teleportation: WebXRMotionControllerTeleportation;
  49361. private constructor();
  49362. /**
  49363. * Creates the default xr experience
  49364. * @param scene scene
  49365. * @param options options for basic configuration
  49366. * @returns resulting WebXRDefaultExperience
  49367. */
  49368. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49369. /**
  49370. * DIsposes of the experience helper
  49371. */
  49372. dispose(): void;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * Options to modify the vr teleportation behavior.
  49378. */
  49379. export interface VRTeleportationOptions {
  49380. /**
  49381. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49382. */
  49383. floorMeshName?: string;
  49384. /**
  49385. * A list of meshes to be used as the teleportation floor. (default: empty)
  49386. */
  49387. floorMeshes?: Mesh[];
  49388. /**
  49389. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49390. */
  49391. teleportationMode?: number;
  49392. /**
  49393. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49394. */
  49395. teleportationTime?: number;
  49396. /**
  49397. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49398. */
  49399. teleportationSpeed?: number;
  49400. /**
  49401. * The easing function used in the animation or null for Linear. (default CircleEase)
  49402. */
  49403. easingFunction?: EasingFunction;
  49404. }
  49405. /**
  49406. * Options to modify the vr experience helper's behavior.
  49407. */
  49408. export interface VRExperienceHelperOptions extends WebVROptions {
  49409. /**
  49410. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49411. */
  49412. createDeviceOrientationCamera?: boolean;
  49413. /**
  49414. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49415. */
  49416. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49417. /**
  49418. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49419. */
  49420. laserToggle?: boolean;
  49421. /**
  49422. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49423. */
  49424. floorMeshes?: Mesh[];
  49425. /**
  49426. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49427. */
  49428. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49429. /**
  49430. * Defines if WebXR should be used instead of WebVR (if available)
  49431. */
  49432. useXR?: boolean;
  49433. }
  49434. /**
  49435. * Event containing information after VR has been entered
  49436. */
  49437. export class OnAfterEnteringVRObservableEvent {
  49438. /**
  49439. * If entering vr was successful
  49440. */
  49441. success: boolean;
  49442. }
  49443. /**
  49444. * Helps to quickly add VR support to an existing scene.
  49445. * See https://doc.babylonjs.com/how_to/webvr_helper
  49446. */
  49447. export class VRExperienceHelper {
  49448. /** Options to modify the vr experience helper's behavior. */
  49449. webVROptions: VRExperienceHelperOptions;
  49450. private _scene;
  49451. private _position;
  49452. private _btnVR;
  49453. private _btnVRDisplayed;
  49454. private _webVRsupported;
  49455. private _webVRready;
  49456. private _webVRrequesting;
  49457. private _webVRpresenting;
  49458. private _hasEnteredVR;
  49459. private _fullscreenVRpresenting;
  49460. private _inputElement;
  49461. private _webVRCamera;
  49462. private _vrDeviceOrientationCamera;
  49463. private _deviceOrientationCamera;
  49464. private _existingCamera;
  49465. private _onKeyDown;
  49466. private _onVrDisplayPresentChange;
  49467. private _onVRDisplayChanged;
  49468. private _onVRRequestPresentStart;
  49469. private _onVRRequestPresentComplete;
  49470. /**
  49471. * 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)
  49472. */
  49473. enableGazeEvenWhenNoPointerLock: boolean;
  49474. /**
  49475. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49476. */
  49477. exitVROnDoubleTap: boolean;
  49478. /**
  49479. * Observable raised right before entering VR.
  49480. */
  49481. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49482. /**
  49483. * Observable raised when entering VR has completed.
  49484. */
  49485. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49486. /**
  49487. * Observable raised when exiting VR.
  49488. */
  49489. onExitingVRObservable: Observable<VRExperienceHelper>;
  49490. /**
  49491. * Observable raised when controller mesh is loaded.
  49492. */
  49493. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49494. /** Return this.onEnteringVRObservable
  49495. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49496. */
  49497. get onEnteringVR(): Observable<VRExperienceHelper>;
  49498. /** Return this.onExitingVRObservable
  49499. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49500. */
  49501. get onExitingVR(): Observable<VRExperienceHelper>;
  49502. /** Return this.onControllerMeshLoadedObservable
  49503. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49504. */
  49505. get onControllerMeshLoaded(): Observable<WebVRController>;
  49506. private _rayLength;
  49507. private _useCustomVRButton;
  49508. private _teleportationRequested;
  49509. private _teleportActive;
  49510. private _floorMeshName;
  49511. private _floorMeshesCollection;
  49512. private _teleportationMode;
  49513. private _teleportationTime;
  49514. private _teleportationSpeed;
  49515. private _teleportationEasing;
  49516. private _rotationAllowed;
  49517. private _teleportBackwardsVector;
  49518. private _teleportationTarget;
  49519. private _isDefaultTeleportationTarget;
  49520. private _postProcessMove;
  49521. private _teleportationFillColor;
  49522. private _teleportationBorderColor;
  49523. private _rotationAngle;
  49524. private _haloCenter;
  49525. private _cameraGazer;
  49526. private _padSensibilityUp;
  49527. private _padSensibilityDown;
  49528. private _leftController;
  49529. private _rightController;
  49530. private _gazeColor;
  49531. private _laserColor;
  49532. private _pickedLaserColor;
  49533. private _pickedGazeColor;
  49534. /**
  49535. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49536. */
  49537. onNewMeshSelected: Observable<AbstractMesh>;
  49538. /**
  49539. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49540. * This observable will provide the mesh and the controller used to select the mesh
  49541. */
  49542. onMeshSelectedWithController: Observable<{
  49543. mesh: AbstractMesh;
  49544. controller: WebVRController;
  49545. }>;
  49546. /**
  49547. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49548. */
  49549. onNewMeshPicked: Observable<PickingInfo>;
  49550. private _circleEase;
  49551. /**
  49552. * Observable raised before camera teleportation
  49553. */
  49554. onBeforeCameraTeleport: Observable<Vector3>;
  49555. /**
  49556. * Observable raised after camera teleportation
  49557. */
  49558. onAfterCameraTeleport: Observable<Vector3>;
  49559. /**
  49560. * Observable raised when current selected mesh gets unselected
  49561. */
  49562. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49563. private _raySelectionPredicate;
  49564. /**
  49565. * To be optionaly changed by user to define custom ray selection
  49566. */
  49567. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49568. /**
  49569. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49570. */
  49571. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49572. /**
  49573. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49574. */
  49575. teleportationEnabled: boolean;
  49576. private _defaultHeight;
  49577. private _teleportationInitialized;
  49578. private _interactionsEnabled;
  49579. private _interactionsRequested;
  49580. private _displayGaze;
  49581. private _displayLaserPointer;
  49582. /**
  49583. * The mesh used to display where the user is going to teleport.
  49584. */
  49585. get teleportationTarget(): Mesh;
  49586. /**
  49587. * Sets the mesh to be used to display where the user is going to teleport.
  49588. */
  49589. set teleportationTarget(value: Mesh);
  49590. /**
  49591. * 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
  49592. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49593. * See https://doc.babylonjs.com/resources/baking_transformations
  49594. */
  49595. get gazeTrackerMesh(): Mesh;
  49596. set gazeTrackerMesh(value: Mesh);
  49597. /**
  49598. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49599. */
  49600. updateGazeTrackerScale: boolean;
  49601. /**
  49602. * If the gaze trackers color should be updated when selecting meshes
  49603. */
  49604. updateGazeTrackerColor: boolean;
  49605. /**
  49606. * If the controller laser color should be updated when selecting meshes
  49607. */
  49608. updateControllerLaserColor: boolean;
  49609. /**
  49610. * The gaze tracking mesh corresponding to the left controller
  49611. */
  49612. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49613. /**
  49614. * The gaze tracking mesh corresponding to the right controller
  49615. */
  49616. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49617. /**
  49618. * If the ray of the gaze should be displayed.
  49619. */
  49620. get displayGaze(): boolean;
  49621. /**
  49622. * Sets if the ray of the gaze should be displayed.
  49623. */
  49624. set displayGaze(value: boolean);
  49625. /**
  49626. * If the ray of the LaserPointer should be displayed.
  49627. */
  49628. get displayLaserPointer(): boolean;
  49629. /**
  49630. * Sets if the ray of the LaserPointer should be displayed.
  49631. */
  49632. set displayLaserPointer(value: boolean);
  49633. /**
  49634. * The deviceOrientationCamera used as the camera when not in VR.
  49635. */
  49636. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49637. /**
  49638. * Based on the current WebVR support, returns the current VR camera used.
  49639. */
  49640. get currentVRCamera(): Nullable<Camera>;
  49641. /**
  49642. * The webVRCamera which is used when in VR.
  49643. */
  49644. get webVRCamera(): WebVRFreeCamera;
  49645. /**
  49646. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49647. */
  49648. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49649. /**
  49650. * The html button that is used to trigger entering into VR.
  49651. */
  49652. get vrButton(): Nullable<HTMLButtonElement>;
  49653. private get _teleportationRequestInitiated();
  49654. /**
  49655. * Defines whether or not Pointer lock should be requested when switching to
  49656. * full screen.
  49657. */
  49658. requestPointerLockOnFullScreen: boolean;
  49659. /**
  49660. * If asking to force XR, this will be populated with the default xr experience
  49661. */
  49662. xr: WebXRDefaultExperience;
  49663. /**
  49664. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49665. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49666. */
  49667. xrTestDone: boolean;
  49668. /**
  49669. * Instantiates a VRExperienceHelper.
  49670. * Helps to quickly add VR support to an existing scene.
  49671. * @param scene The scene the VRExperienceHelper belongs to.
  49672. * @param webVROptions Options to modify the vr experience helper's behavior.
  49673. */
  49674. constructor(scene: Scene,
  49675. /** Options to modify the vr experience helper's behavior. */
  49676. webVROptions?: VRExperienceHelperOptions);
  49677. private completeVRInit;
  49678. private _onDefaultMeshLoaded;
  49679. private _onResize;
  49680. private _onFullscreenChange;
  49681. /**
  49682. * Gets a value indicating if we are currently in VR mode.
  49683. */
  49684. get isInVRMode(): boolean;
  49685. private onVrDisplayPresentChange;
  49686. private onVRDisplayChanged;
  49687. private moveButtonToBottomRight;
  49688. private displayVRButton;
  49689. private updateButtonVisibility;
  49690. private _cachedAngularSensibility;
  49691. /**
  49692. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49693. * Otherwise, will use the fullscreen API.
  49694. */
  49695. enterVR(): void;
  49696. /**
  49697. * Attempt to exit VR, or fullscreen.
  49698. */
  49699. exitVR(): void;
  49700. /**
  49701. * The position of the vr experience helper.
  49702. */
  49703. get position(): Vector3;
  49704. /**
  49705. * Sets the position of the vr experience helper.
  49706. */
  49707. set position(value: Vector3);
  49708. /**
  49709. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49710. */
  49711. enableInteractions(): void;
  49712. private get _noControllerIsActive();
  49713. private beforeRender;
  49714. private _isTeleportationFloor;
  49715. /**
  49716. * Adds a floor mesh to be used for teleportation.
  49717. * @param floorMesh the mesh to be used for teleportation.
  49718. */
  49719. addFloorMesh(floorMesh: Mesh): void;
  49720. /**
  49721. * Removes a floor mesh from being used for teleportation.
  49722. * @param floorMesh the mesh to be removed.
  49723. */
  49724. removeFloorMesh(floorMesh: Mesh): void;
  49725. /**
  49726. * Enables interactions and teleportation using the VR controllers and gaze.
  49727. * @param vrTeleportationOptions options to modify teleportation behavior.
  49728. */
  49729. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49730. private _onNewGamepadConnected;
  49731. private _tryEnableInteractionOnController;
  49732. private _onNewGamepadDisconnected;
  49733. private _enableInteractionOnController;
  49734. private _checkTeleportWithRay;
  49735. private _checkRotate;
  49736. private _checkTeleportBackwards;
  49737. private _enableTeleportationOnController;
  49738. private _createTeleportationCircles;
  49739. private _displayTeleportationTarget;
  49740. private _hideTeleportationTarget;
  49741. private _rotateCamera;
  49742. private _moveTeleportationSelectorTo;
  49743. private _workingVector;
  49744. private _workingQuaternion;
  49745. private _workingMatrix;
  49746. /**
  49747. * Time Constant Teleportation Mode
  49748. */
  49749. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49750. /**
  49751. * Speed Constant Teleportation Mode
  49752. */
  49753. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49754. /**
  49755. * Teleports the users feet to the desired location
  49756. * @param location The location where the user's feet should be placed
  49757. */
  49758. teleportCamera(location: Vector3): void;
  49759. private _convertNormalToDirectionOfRay;
  49760. private _castRayAndSelectObject;
  49761. private _notifySelectedMeshUnselected;
  49762. /**
  49763. * Permanently set new colors for the laser pointer
  49764. * @param color the new laser color
  49765. * @param pickedColor the new laser color when picked mesh detected
  49766. */
  49767. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49768. /**
  49769. * Set lighting enabled / disabled on the laser pointer of both controllers
  49770. * @param enabled should the lighting be enabled on the laser pointer
  49771. */
  49772. setLaserLightingState(enabled?: boolean): void;
  49773. /**
  49774. * Permanently set new colors for the gaze pointer
  49775. * @param color the new gaze color
  49776. * @param pickedColor the new gaze color when picked mesh detected
  49777. */
  49778. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49779. /**
  49780. * Sets the color of the laser ray from the vr controllers.
  49781. * @param color new color for the ray.
  49782. */
  49783. changeLaserColor(color: Color3): void;
  49784. /**
  49785. * Sets the color of the ray from the vr headsets gaze.
  49786. * @param color new color for the ray.
  49787. */
  49788. changeGazeColor(color: Color3): void;
  49789. /**
  49790. * Exits VR and disposes of the vr experience helper
  49791. */
  49792. dispose(): void;
  49793. /**
  49794. * Gets the name of the VRExperienceHelper class
  49795. * @returns "VRExperienceHelper"
  49796. */
  49797. getClassName(): string;
  49798. }
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * Contains an array of blocks representing the octree
  49803. */
  49804. export interface IOctreeContainer<T> {
  49805. /**
  49806. * Blocks within the octree
  49807. */
  49808. blocks: Array<OctreeBlock<T>>;
  49809. }
  49810. /**
  49811. * Class used to store a cell in an octree
  49812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49813. */
  49814. export class OctreeBlock<T> {
  49815. /**
  49816. * Gets the content of the current block
  49817. */
  49818. entries: T[];
  49819. /**
  49820. * Gets the list of block children
  49821. */
  49822. blocks: Array<OctreeBlock<T>>;
  49823. private _depth;
  49824. private _maxDepth;
  49825. private _capacity;
  49826. private _minPoint;
  49827. private _maxPoint;
  49828. private _boundingVectors;
  49829. private _creationFunc;
  49830. /**
  49831. * Creates a new block
  49832. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49833. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49834. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49835. * @param depth defines the current depth of this block in the octree
  49836. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49837. * @param creationFunc defines a callback to call when an element is added to the block
  49838. */
  49839. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49840. /**
  49841. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49842. */
  49843. get capacity(): number;
  49844. /**
  49845. * Gets the minimum vector (in world space) of the block's bounding box
  49846. */
  49847. get minPoint(): Vector3;
  49848. /**
  49849. * Gets the maximum vector (in world space) of the block's bounding box
  49850. */
  49851. get maxPoint(): Vector3;
  49852. /**
  49853. * Add a new element to this block
  49854. * @param entry defines the element to add
  49855. */
  49856. addEntry(entry: T): void;
  49857. /**
  49858. * Remove an element from this block
  49859. * @param entry defines the element to remove
  49860. */
  49861. removeEntry(entry: T): void;
  49862. /**
  49863. * Add an array of elements to this block
  49864. * @param entries defines the array of elements to add
  49865. */
  49866. addEntries(entries: T[]): void;
  49867. /**
  49868. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49869. * @param frustumPlanes defines the frustum planes to test
  49870. * @param selection defines the array to store current content if selection is positive
  49871. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49872. */
  49873. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49874. /**
  49875. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49876. * @param sphereCenter defines the bounding sphere center
  49877. * @param sphereRadius defines the bounding sphere radius
  49878. * @param selection defines the array to store current content if selection is positive
  49879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49880. */
  49881. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49882. /**
  49883. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49884. * @param ray defines the ray to test with
  49885. * @param selection defines the array to store current content if selection is positive
  49886. */
  49887. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49888. /**
  49889. * Subdivide the content into child blocks (this block will then be empty)
  49890. */
  49891. createInnerBlocks(): void;
  49892. /**
  49893. * @hidden
  49894. */
  49895. 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;
  49896. }
  49897. }
  49898. declare module BABYLON {
  49899. /**
  49900. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49901. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49902. */
  49903. export class Octree<T> {
  49904. /** 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.) */
  49905. maxDepth: number;
  49906. /**
  49907. * Blocks within the octree containing objects
  49908. */
  49909. blocks: Array<OctreeBlock<T>>;
  49910. /**
  49911. * Content stored in the octree
  49912. */
  49913. dynamicContent: T[];
  49914. private _maxBlockCapacity;
  49915. private _selectionContent;
  49916. private _creationFunc;
  49917. /**
  49918. * Creates a octree
  49919. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49920. * @param creationFunc function to be used to instatiate the octree
  49921. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49922. * @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.)
  49923. */
  49924. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49925. /** 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.) */
  49926. maxDepth?: number);
  49927. /**
  49928. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49929. * @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);
  49930. * @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);
  49931. * @param entries meshes to be added to the octree blocks
  49932. */
  49933. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49934. /**
  49935. * Adds a mesh to the octree
  49936. * @param entry Mesh to add to the octree
  49937. */
  49938. addMesh(entry: T): void;
  49939. /**
  49940. * Remove an element from the octree
  49941. * @param entry defines the element to remove
  49942. */
  49943. removeMesh(entry: T): void;
  49944. /**
  49945. * Selects an array of meshes within the frustum
  49946. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49947. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49948. * @returns array of meshes within the frustum
  49949. */
  49950. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49951. /**
  49952. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49953. * @param sphereCenter defines the bounding sphere center
  49954. * @param sphereRadius defines the bounding sphere radius
  49955. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49956. * @returns an array of objects that intersect the sphere
  49957. */
  49958. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49959. /**
  49960. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49961. * @param ray defines the ray to test with
  49962. * @returns array of intersected objects
  49963. */
  49964. intersectsRay(ray: Ray): SmartArray<T>;
  49965. /**
  49966. * Adds a mesh into the octree block if it intersects the block
  49967. */
  49968. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49969. /**
  49970. * Adds a submesh into the octree block if it intersects the block
  49971. */
  49972. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49973. }
  49974. }
  49975. declare module BABYLON {
  49976. interface Scene {
  49977. /**
  49978. * @hidden
  49979. * Backing Filed
  49980. */
  49981. _selectionOctree: Octree<AbstractMesh>;
  49982. /**
  49983. * Gets the octree used to boost mesh selection (picking)
  49984. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49985. */
  49986. selectionOctree: Octree<AbstractMesh>;
  49987. /**
  49988. * Creates or updates the octree used to boost selection (picking)
  49989. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49990. * @param maxCapacity defines the maximum capacity per leaf
  49991. * @param maxDepth defines the maximum depth of the octree
  49992. * @returns an octree of AbstractMesh
  49993. */
  49994. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49995. }
  49996. interface AbstractMesh {
  49997. /**
  49998. * @hidden
  49999. * Backing Field
  50000. */
  50001. _submeshesOctree: Octree<SubMesh>;
  50002. /**
  50003. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50004. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50005. * @param maxCapacity defines the maximum size of each block (64 by default)
  50006. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50007. * @returns the new octree
  50008. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50009. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50010. */
  50011. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50012. }
  50013. /**
  50014. * Defines the octree scene component responsible to manage any octrees
  50015. * in a given scene.
  50016. */
  50017. export class OctreeSceneComponent {
  50018. /**
  50019. * The component name help to identify the component in the list of scene components.
  50020. */
  50021. readonly name: string;
  50022. /**
  50023. * The scene the component belongs to.
  50024. */
  50025. scene: Scene;
  50026. /**
  50027. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50028. */
  50029. readonly checksIsEnabled: boolean;
  50030. /**
  50031. * Creates a new instance of the component for the given scene
  50032. * @param scene Defines the scene to register the component in
  50033. */
  50034. constructor(scene: Scene);
  50035. /**
  50036. * Registers the component in a given scene
  50037. */
  50038. register(): void;
  50039. /**
  50040. * Return the list of active meshes
  50041. * @returns the list of active meshes
  50042. */
  50043. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50044. /**
  50045. * Return the list of active sub meshes
  50046. * @param mesh The mesh to get the candidates sub meshes from
  50047. * @returns the list of active sub meshes
  50048. */
  50049. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50050. private _tempRay;
  50051. /**
  50052. * Return the list of sub meshes intersecting with a given local ray
  50053. * @param mesh defines the mesh to find the submesh for
  50054. * @param localRay defines the ray in local space
  50055. * @returns the list of intersecting sub meshes
  50056. */
  50057. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50058. /**
  50059. * Return the list of sub meshes colliding with a collider
  50060. * @param mesh defines the mesh to find the submesh for
  50061. * @param collider defines the collider to evaluate the collision against
  50062. * @returns the list of colliding sub meshes
  50063. */
  50064. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50065. /**
  50066. * Rebuilds the elements related to this component in case of
  50067. * context lost for instance.
  50068. */
  50069. rebuild(): void;
  50070. /**
  50071. * Disposes the component and the associated ressources.
  50072. */
  50073. dispose(): void;
  50074. }
  50075. }
  50076. declare module BABYLON {
  50077. /**
  50078. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50079. */
  50080. export class Gizmo implements IDisposable {
  50081. /** The utility layer the gizmo will be added to */
  50082. gizmoLayer: UtilityLayerRenderer;
  50083. /**
  50084. * The root mesh of the gizmo
  50085. */
  50086. _rootMesh: Mesh;
  50087. private _attachedMesh;
  50088. private _attachedNode;
  50089. /**
  50090. * Ratio for the scale of the gizmo (Default: 1)
  50091. */
  50092. scaleRatio: number;
  50093. /**
  50094. * If a custom mesh has been set (Default: false)
  50095. */
  50096. protected _customMeshSet: boolean;
  50097. /**
  50098. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50099. * * When set, interactions will be enabled
  50100. */
  50101. get attachedMesh(): Nullable<AbstractMesh>;
  50102. set attachedMesh(value: Nullable<AbstractMesh>);
  50103. /**
  50104. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50105. * * When set, interactions will be enabled
  50106. */
  50107. get attachedNode(): Nullable<Node>;
  50108. set attachedNode(value: Nullable<Node>);
  50109. /**
  50110. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50111. * @param mesh The mesh to replace the default mesh of the gizmo
  50112. */
  50113. setCustomMesh(mesh: Mesh): void;
  50114. /**
  50115. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50116. */
  50117. updateGizmoRotationToMatchAttachedMesh: boolean;
  50118. /**
  50119. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50120. */
  50121. updateGizmoPositionToMatchAttachedMesh: boolean;
  50122. /**
  50123. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50124. */
  50125. updateScale: boolean;
  50126. protected _interactionsEnabled: boolean;
  50127. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50128. private _beforeRenderObserver;
  50129. private _tempVector;
  50130. /**
  50131. * Creates a gizmo
  50132. * @param gizmoLayer The utility layer the gizmo will be added to
  50133. */
  50134. constructor(
  50135. /** The utility layer the gizmo will be added to */
  50136. gizmoLayer?: UtilityLayerRenderer);
  50137. /**
  50138. * Updates the gizmo to match the attached mesh's position/rotation
  50139. */
  50140. protected _update(): void;
  50141. /**
  50142. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50143. * @param value Node, TransformNode or mesh
  50144. */
  50145. protected _matrixChanged(): void;
  50146. /**
  50147. * Disposes of the gizmo
  50148. */
  50149. dispose(): void;
  50150. }
  50151. }
  50152. declare module BABYLON {
  50153. /**
  50154. * Single plane drag gizmo
  50155. */
  50156. export class PlaneDragGizmo extends Gizmo {
  50157. /**
  50158. * Drag behavior responsible for the gizmos dragging interactions
  50159. */
  50160. dragBehavior: PointerDragBehavior;
  50161. private _pointerObserver;
  50162. /**
  50163. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50164. */
  50165. snapDistance: number;
  50166. /**
  50167. * Event that fires each time the gizmo snaps to a new location.
  50168. * * snapDistance is the the change in distance
  50169. */
  50170. onSnapObservable: Observable<{
  50171. snapDistance: number;
  50172. }>;
  50173. private _plane;
  50174. private _coloredMaterial;
  50175. private _hoverMaterial;
  50176. private _isEnabled;
  50177. private _parent;
  50178. /** @hidden */
  50179. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50180. /** @hidden */
  50181. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50182. /**
  50183. * Creates a PlaneDragGizmo
  50184. * @param gizmoLayer The utility layer the gizmo will be added to
  50185. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50186. * @param color The color of the gizmo
  50187. */
  50188. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50189. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50190. /**
  50191. * If the gizmo is enabled
  50192. */
  50193. set isEnabled(value: boolean);
  50194. get isEnabled(): boolean;
  50195. /**
  50196. * Disposes of the gizmo
  50197. */
  50198. dispose(): void;
  50199. }
  50200. }
  50201. declare module BABYLON {
  50202. /**
  50203. * Gizmo that enables dragging a mesh along 3 axis
  50204. */
  50205. export class PositionGizmo extends Gizmo {
  50206. /**
  50207. * Internal gizmo used for interactions on the x axis
  50208. */
  50209. xGizmo: AxisDragGizmo;
  50210. /**
  50211. * Internal gizmo used for interactions on the y axis
  50212. */
  50213. yGizmo: AxisDragGizmo;
  50214. /**
  50215. * Internal gizmo used for interactions on the z axis
  50216. */
  50217. zGizmo: AxisDragGizmo;
  50218. /**
  50219. * Internal gizmo used for interactions on the yz plane
  50220. */
  50221. xPlaneGizmo: PlaneDragGizmo;
  50222. /**
  50223. * Internal gizmo used for interactions on the xz plane
  50224. */
  50225. yPlaneGizmo: PlaneDragGizmo;
  50226. /**
  50227. * Internal gizmo used for interactions on the xy plane
  50228. */
  50229. zPlaneGizmo: PlaneDragGizmo;
  50230. /**
  50231. * private variables
  50232. */
  50233. private _meshAttached;
  50234. private _nodeAttached;
  50235. private _updateGizmoRotationToMatchAttachedMesh;
  50236. private _snapDistance;
  50237. private _scaleRatio;
  50238. /** Fires an event when any of it's sub gizmos are dragged */
  50239. onDragStartObservable: Observable<unknown>;
  50240. /** Fires an event when any of it's sub gizmos are released from dragging */
  50241. onDragEndObservable: Observable<unknown>;
  50242. /**
  50243. * If set to true, planar drag is enabled
  50244. */
  50245. private _planarGizmoEnabled;
  50246. get attachedMesh(): Nullable<AbstractMesh>;
  50247. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50248. get attachedNode(): Nullable<Node>;
  50249. set attachedNode(node: Nullable<Node>);
  50250. /**
  50251. * Creates a PositionGizmo
  50252. * @param gizmoLayer The utility layer the gizmo will be added to
  50253. @param thickness display gizmo axis thickness
  50254. */
  50255. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50256. /**
  50257. * If the planar drag gizmo is enabled
  50258. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50259. */
  50260. set planarGizmoEnabled(value: boolean);
  50261. get planarGizmoEnabled(): boolean;
  50262. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50263. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50264. /**
  50265. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50266. */
  50267. set snapDistance(value: number);
  50268. get snapDistance(): number;
  50269. /**
  50270. * Ratio for the scale of the gizmo (Default: 1)
  50271. */
  50272. set scaleRatio(value: number);
  50273. get scaleRatio(): number;
  50274. /**
  50275. * Disposes of the gizmo
  50276. */
  50277. dispose(): void;
  50278. /**
  50279. * CustomMeshes are not supported by this gizmo
  50280. * @param mesh The mesh to replace the default mesh of the gizmo
  50281. */
  50282. setCustomMesh(mesh: Mesh): void;
  50283. }
  50284. }
  50285. declare module BABYLON {
  50286. /**
  50287. * Single axis drag gizmo
  50288. */
  50289. export class AxisDragGizmo extends Gizmo {
  50290. /**
  50291. * Drag behavior responsible for the gizmos dragging interactions
  50292. */
  50293. dragBehavior: PointerDragBehavior;
  50294. private _pointerObserver;
  50295. /**
  50296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50297. */
  50298. snapDistance: number;
  50299. /**
  50300. * Event that fires each time the gizmo snaps to a new location.
  50301. * * snapDistance is the the change in distance
  50302. */
  50303. onSnapObservable: Observable<{
  50304. snapDistance: number;
  50305. }>;
  50306. private _isEnabled;
  50307. private _parent;
  50308. private _arrow;
  50309. private _coloredMaterial;
  50310. private _hoverMaterial;
  50311. /** @hidden */
  50312. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50313. /** @hidden */
  50314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50315. /**
  50316. * Creates an AxisDragGizmo
  50317. * @param gizmoLayer The utility layer the gizmo will be added to
  50318. * @param dragAxis The axis which the gizmo will be able to drag on
  50319. * @param color The color of the gizmo
  50320. * @param thickness display gizmo axis thickness
  50321. */
  50322. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50323. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50324. /**
  50325. * If the gizmo is enabled
  50326. */
  50327. set isEnabled(value: boolean);
  50328. get isEnabled(): boolean;
  50329. /**
  50330. * Disposes of the gizmo
  50331. */
  50332. dispose(): void;
  50333. }
  50334. }
  50335. declare module BABYLON.Debug {
  50336. /**
  50337. * The Axes viewer will show 3 axes in a specific point in space
  50338. */
  50339. export class AxesViewer {
  50340. private _xAxis;
  50341. private _yAxis;
  50342. private _zAxis;
  50343. private _scaleLinesFactor;
  50344. private _instanced;
  50345. /**
  50346. * Gets the hosting scene
  50347. */
  50348. scene: Scene;
  50349. /**
  50350. * Gets or sets a number used to scale line length
  50351. */
  50352. scaleLines: number;
  50353. /** Gets the node hierarchy used to render x-axis */
  50354. get xAxis(): TransformNode;
  50355. /** Gets the node hierarchy used to render y-axis */
  50356. get yAxis(): TransformNode;
  50357. /** Gets the node hierarchy used to render z-axis */
  50358. get zAxis(): TransformNode;
  50359. /**
  50360. * Creates a new AxesViewer
  50361. * @param scene defines the hosting scene
  50362. * @param scaleLines defines a number used to scale line length (1 by default)
  50363. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50364. * @param xAxis defines the node hierarchy used to render the x-axis
  50365. * @param yAxis defines the node hierarchy used to render the y-axis
  50366. * @param zAxis defines the node hierarchy used to render the z-axis
  50367. */
  50368. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50369. /**
  50370. * Force the viewer to update
  50371. * @param position defines the position of the viewer
  50372. * @param xaxis defines the x axis of the viewer
  50373. * @param yaxis defines the y axis of the viewer
  50374. * @param zaxis defines the z axis of the viewer
  50375. */
  50376. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50377. /**
  50378. * Creates an instance of this axes viewer.
  50379. * @returns a new axes viewer with instanced meshes
  50380. */
  50381. createInstance(): AxesViewer;
  50382. /** Releases resources */
  50383. dispose(): void;
  50384. private static _SetRenderingGroupId;
  50385. }
  50386. }
  50387. declare module BABYLON.Debug {
  50388. /**
  50389. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50390. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50391. */
  50392. export class BoneAxesViewer extends AxesViewer {
  50393. /**
  50394. * Gets or sets the target mesh where to display the axes viewer
  50395. */
  50396. mesh: Nullable<Mesh>;
  50397. /**
  50398. * Gets or sets the target bone where to display the axes viewer
  50399. */
  50400. bone: Nullable<Bone>;
  50401. /** Gets current position */
  50402. pos: Vector3;
  50403. /** Gets direction of X axis */
  50404. xaxis: Vector3;
  50405. /** Gets direction of Y axis */
  50406. yaxis: Vector3;
  50407. /** Gets direction of Z axis */
  50408. zaxis: Vector3;
  50409. /**
  50410. * Creates a new BoneAxesViewer
  50411. * @param scene defines the hosting scene
  50412. * @param bone defines the target bone
  50413. * @param mesh defines the target mesh
  50414. * @param scaleLines defines a scaling factor for line length (1 by default)
  50415. */
  50416. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50417. /**
  50418. * Force the viewer to update
  50419. */
  50420. update(): void;
  50421. /** Releases resources */
  50422. dispose(): void;
  50423. }
  50424. }
  50425. declare module BABYLON {
  50426. /**
  50427. * Interface used to define scene explorer extensibility option
  50428. */
  50429. export interface IExplorerExtensibilityOption {
  50430. /**
  50431. * Define the option label
  50432. */
  50433. label: string;
  50434. /**
  50435. * Defines the action to execute on click
  50436. */
  50437. action: (entity: any) => void;
  50438. }
  50439. /**
  50440. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50441. */
  50442. export interface IExplorerExtensibilityGroup {
  50443. /**
  50444. * Defines a predicate to test if a given type mut be extended
  50445. */
  50446. predicate: (entity: any) => boolean;
  50447. /**
  50448. * Gets the list of options added to a type
  50449. */
  50450. entries: IExplorerExtensibilityOption[];
  50451. }
  50452. /**
  50453. * Interface used to define the options to use to create the Inspector
  50454. */
  50455. export interface IInspectorOptions {
  50456. /**
  50457. * Display in overlay mode (default: false)
  50458. */
  50459. overlay?: boolean;
  50460. /**
  50461. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50462. */
  50463. globalRoot?: HTMLElement;
  50464. /**
  50465. * Display the Scene explorer
  50466. */
  50467. showExplorer?: boolean;
  50468. /**
  50469. * Display the property inspector
  50470. */
  50471. showInspector?: boolean;
  50472. /**
  50473. * Display in embed mode (both panes on the right)
  50474. */
  50475. embedMode?: boolean;
  50476. /**
  50477. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50478. */
  50479. handleResize?: boolean;
  50480. /**
  50481. * Allow the panes to popup (default: true)
  50482. */
  50483. enablePopup?: boolean;
  50484. /**
  50485. * Allow the panes to be closed by users (default: true)
  50486. */
  50487. enableClose?: boolean;
  50488. /**
  50489. * Optional list of extensibility entries
  50490. */
  50491. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50492. /**
  50493. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50494. */
  50495. inspectorURL?: string;
  50496. /**
  50497. * Optional initial tab (default to DebugLayerTab.Properties)
  50498. */
  50499. initialTab?: DebugLayerTab;
  50500. }
  50501. interface Scene {
  50502. /**
  50503. * @hidden
  50504. * Backing field
  50505. */
  50506. _debugLayer: DebugLayer;
  50507. /**
  50508. * Gets the debug layer (aka Inspector) associated with the scene
  50509. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50510. */
  50511. debugLayer: DebugLayer;
  50512. }
  50513. /**
  50514. * Enum of inspector action tab
  50515. */
  50516. export enum DebugLayerTab {
  50517. /**
  50518. * Properties tag (default)
  50519. */
  50520. Properties = 0,
  50521. /**
  50522. * Debug tab
  50523. */
  50524. Debug = 1,
  50525. /**
  50526. * Statistics tab
  50527. */
  50528. Statistics = 2,
  50529. /**
  50530. * Tools tab
  50531. */
  50532. Tools = 3,
  50533. /**
  50534. * Settings tab
  50535. */
  50536. Settings = 4
  50537. }
  50538. /**
  50539. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50540. * what is happening in your scene
  50541. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50542. */
  50543. export class DebugLayer {
  50544. /**
  50545. * Define the url to get the inspector script from.
  50546. * By default it uses the babylonjs CDN.
  50547. * @ignoreNaming
  50548. */
  50549. static InspectorURL: string;
  50550. private _scene;
  50551. private BJSINSPECTOR;
  50552. private _onPropertyChangedObservable?;
  50553. /**
  50554. * Observable triggered when a property is changed through the inspector.
  50555. */
  50556. get onPropertyChangedObservable(): any;
  50557. /**
  50558. * Instantiates a new debug layer.
  50559. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50560. * what is happening in your scene
  50561. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50562. * @param scene Defines the scene to inspect
  50563. */
  50564. constructor(scene: Scene);
  50565. /** Creates the inspector window. */
  50566. private _createInspector;
  50567. /**
  50568. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50569. * @param entity defines the entity to select
  50570. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50571. */
  50572. select(entity: any, lineContainerTitles?: string | string[]): void;
  50573. /** Get the inspector from bundle or global */
  50574. private _getGlobalInspector;
  50575. /**
  50576. * Get if the inspector is visible or not.
  50577. * @returns true if visible otherwise, false
  50578. */
  50579. isVisible(): boolean;
  50580. /**
  50581. * Hide the inspector and close its window.
  50582. */
  50583. hide(): void;
  50584. /**
  50585. * Update the scene in the inspector
  50586. */
  50587. setAsActiveScene(): void;
  50588. /**
  50589. * Launch the debugLayer.
  50590. * @param config Define the configuration of the inspector
  50591. * @return a promise fulfilled when the debug layer is visible
  50592. */
  50593. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50594. }
  50595. }
  50596. declare module BABYLON {
  50597. /**
  50598. * Class containing static functions to help procedurally build meshes
  50599. */
  50600. export class BoxBuilder {
  50601. /**
  50602. * Creates a box mesh
  50603. * * The parameter `size` sets the size (float) of each box side (default 1)
  50604. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50605. * * 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)
  50606. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50608. * * 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
  50609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50610. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50611. * @param name defines the name of the mesh
  50612. * @param options defines the options used to create the mesh
  50613. * @param scene defines the hosting scene
  50614. * @returns the box mesh
  50615. */
  50616. static CreateBox(name: string, options: {
  50617. size?: number;
  50618. width?: number;
  50619. height?: number;
  50620. depth?: number;
  50621. faceUV?: Vector4[];
  50622. faceColors?: Color4[];
  50623. sideOrientation?: number;
  50624. frontUVs?: Vector4;
  50625. backUVs?: Vector4;
  50626. wrap?: boolean;
  50627. topBaseAt?: number;
  50628. bottomBaseAt?: number;
  50629. updatable?: boolean;
  50630. }, scene?: Nullable<Scene>): Mesh;
  50631. }
  50632. }
  50633. declare module BABYLON.Debug {
  50634. /**
  50635. * Used to show the physics impostor around the specific mesh
  50636. */
  50637. export class PhysicsViewer {
  50638. /** @hidden */
  50639. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50640. /** @hidden */
  50641. protected _meshes: Array<Nullable<AbstractMesh>>;
  50642. /** @hidden */
  50643. protected _scene: Nullable<Scene>;
  50644. /** @hidden */
  50645. protected _numMeshes: number;
  50646. /** @hidden */
  50647. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50648. private _renderFunction;
  50649. private _utilityLayer;
  50650. private _debugBoxMesh;
  50651. private _debugSphereMesh;
  50652. private _debugCylinderMesh;
  50653. private _debugMaterial;
  50654. private _debugMeshMeshes;
  50655. /**
  50656. * Creates a new PhysicsViewer
  50657. * @param scene defines the hosting scene
  50658. */
  50659. constructor(scene: Scene);
  50660. /** @hidden */
  50661. protected _updateDebugMeshes(): void;
  50662. /**
  50663. * Renders a specified physic impostor
  50664. * @param impostor defines the impostor to render
  50665. * @param targetMesh defines the mesh represented by the impostor
  50666. * @returns the new debug mesh used to render the impostor
  50667. */
  50668. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50669. /**
  50670. * Hides a specified physic impostor
  50671. * @param impostor defines the impostor to hide
  50672. */
  50673. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50674. private _getDebugMaterial;
  50675. private _getDebugBoxMesh;
  50676. private _getDebugSphereMesh;
  50677. private _getDebugCylinderMesh;
  50678. private _getDebugMeshMesh;
  50679. private _getDebugMesh;
  50680. /** Releases all resources */
  50681. dispose(): void;
  50682. }
  50683. }
  50684. declare module BABYLON {
  50685. /**
  50686. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50687. * in order to better appreciate the issue one might have.
  50688. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50689. */
  50690. export class RayHelper {
  50691. /**
  50692. * Defines the ray we are currently tryin to visualize.
  50693. */
  50694. ray: Nullable<Ray>;
  50695. private _renderPoints;
  50696. private _renderLine;
  50697. private _renderFunction;
  50698. private _scene;
  50699. private _updateToMeshFunction;
  50700. private _attachedToMesh;
  50701. private _meshSpaceDirection;
  50702. private _meshSpaceOrigin;
  50703. /**
  50704. * Helper function to create a colored helper in a scene in one line.
  50705. * @param ray Defines the ray we are currently tryin to visualize
  50706. * @param scene Defines the scene the ray is used in
  50707. * @param color Defines the color we want to see the ray in
  50708. * @returns The newly created ray helper.
  50709. */
  50710. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50711. /**
  50712. * Instantiate a new ray helper.
  50713. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50714. * in order to better appreciate the issue one might have.
  50715. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50716. * @param ray Defines the ray we are currently tryin to visualize
  50717. */
  50718. constructor(ray: Ray);
  50719. /**
  50720. * Shows the ray we are willing to debug.
  50721. * @param scene Defines the scene the ray needs to be rendered in
  50722. * @param color Defines the color the ray needs to be rendered in
  50723. */
  50724. show(scene: Scene, color?: Color3): void;
  50725. /**
  50726. * Hides the ray we are debugging.
  50727. */
  50728. hide(): void;
  50729. private _render;
  50730. /**
  50731. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50732. * @param mesh Defines the mesh we want the helper attached to
  50733. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50734. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50735. * @param length Defines the length of the ray
  50736. */
  50737. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50738. /**
  50739. * Detach the ray helper from the mesh it has previously been attached to.
  50740. */
  50741. detachFromMesh(): void;
  50742. private _updateToMesh;
  50743. /**
  50744. * Dispose the helper and release its associated resources.
  50745. */
  50746. dispose(): void;
  50747. }
  50748. }
  50749. declare module BABYLON {
  50750. /**
  50751. * Defines the options associated with the creation of a SkeletonViewer.
  50752. */
  50753. export interface ISkeletonViewerOptions {
  50754. /** Should the system pause animations before building the Viewer? */
  50755. pauseAnimations: boolean;
  50756. /** Should the system return the skeleton to rest before building? */
  50757. returnToRest: boolean;
  50758. /** public Display Mode of the Viewer */
  50759. displayMode: number;
  50760. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50761. displayOptions: ISkeletonViewerDisplayOptions;
  50762. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50763. computeBonesUsingShaders: boolean;
  50764. }
  50765. /**
  50766. * Defines how to display the various bone meshes for the viewer.
  50767. */
  50768. export interface ISkeletonViewerDisplayOptions {
  50769. /** How far down to start tapering the bone spurs */
  50770. midStep?: number;
  50771. /** How big is the midStep? */
  50772. midStepFactor?: number;
  50773. /** Base for the Sphere Size */
  50774. sphereBaseSize?: number;
  50775. /** The ratio of the sphere to the longest bone in units */
  50776. sphereScaleUnit?: number;
  50777. /** Ratio for the Sphere Size */
  50778. sphereFactor?: number;
  50779. }
  50780. }
  50781. declare module BABYLON {
  50782. /**
  50783. * Class containing static functions to help procedurally build meshes
  50784. */
  50785. export class RibbonBuilder {
  50786. /**
  50787. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50788. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50789. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50790. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50791. * * 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
  50792. * * 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
  50793. * * 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
  50794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50795. * * 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
  50796. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50797. * * 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
  50798. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50799. * * 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
  50800. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50802. * @param name defines the name of the mesh
  50803. * @param options defines the options used to create the mesh
  50804. * @param scene defines the hosting scene
  50805. * @returns the ribbon mesh
  50806. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50807. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50808. */
  50809. static CreateRibbon(name: string, options: {
  50810. pathArray: Vector3[][];
  50811. closeArray?: boolean;
  50812. closePath?: boolean;
  50813. offset?: number;
  50814. updatable?: boolean;
  50815. sideOrientation?: number;
  50816. frontUVs?: Vector4;
  50817. backUVs?: Vector4;
  50818. instance?: Mesh;
  50819. invertUV?: boolean;
  50820. uvs?: Vector2[];
  50821. colors?: Color4[];
  50822. }, scene?: Nullable<Scene>): Mesh;
  50823. }
  50824. }
  50825. declare module BABYLON {
  50826. /**
  50827. * Class containing static functions to help procedurally build meshes
  50828. */
  50829. export class ShapeBuilder {
  50830. /**
  50831. * 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.
  50832. * * 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.
  50833. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50834. * * 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.
  50835. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50836. * * 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
  50837. * * 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
  50838. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50840. * * 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
  50841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50843. * @param name defines the name of the mesh
  50844. * @param options defines the options used to create the mesh
  50845. * @param scene defines the hosting scene
  50846. * @returns the extruded shape mesh
  50847. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50849. */
  50850. static ExtrudeShape(name: string, options: {
  50851. shape: Vector3[];
  50852. path: Vector3[];
  50853. scale?: number;
  50854. rotation?: number;
  50855. cap?: number;
  50856. updatable?: boolean;
  50857. sideOrientation?: number;
  50858. frontUVs?: Vector4;
  50859. backUVs?: Vector4;
  50860. instance?: Mesh;
  50861. invertUV?: boolean;
  50862. }, scene?: Nullable<Scene>): Mesh;
  50863. /**
  50864. * Creates an custom extruded shape mesh.
  50865. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50866. * * 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.
  50867. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50868. * * 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
  50869. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50870. * * 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
  50871. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50872. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50873. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50874. * * 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
  50875. * * 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
  50876. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50878. * * 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
  50879. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50881. * @param name defines the name of the mesh
  50882. * @param options defines the options used to create the mesh
  50883. * @param scene defines the hosting scene
  50884. * @returns the custom extruded shape mesh
  50885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50888. */
  50889. static ExtrudeShapeCustom(name: string, options: {
  50890. shape: Vector3[];
  50891. path: Vector3[];
  50892. scaleFunction?: any;
  50893. rotationFunction?: any;
  50894. ribbonCloseArray?: boolean;
  50895. ribbonClosePath?: boolean;
  50896. cap?: number;
  50897. updatable?: boolean;
  50898. sideOrientation?: number;
  50899. frontUVs?: Vector4;
  50900. backUVs?: Vector4;
  50901. instance?: Mesh;
  50902. invertUV?: boolean;
  50903. }, scene?: Nullable<Scene>): Mesh;
  50904. private static _ExtrudeShapeGeneric;
  50905. }
  50906. }
  50907. declare module BABYLON.Debug {
  50908. /**
  50909. * Class used to render a debug view of a given skeleton
  50910. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50911. */
  50912. export class SkeletonViewer {
  50913. /** defines the skeleton to render */
  50914. skeleton: Skeleton;
  50915. /** defines the mesh attached to the skeleton */
  50916. mesh: AbstractMesh;
  50917. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50918. autoUpdateBonesMatrices: boolean;
  50919. /** defines the rendering group id to use with the viewer */
  50920. renderingGroupId: number;
  50921. /** is the options for the viewer */
  50922. options: Partial<ISkeletonViewerOptions>;
  50923. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  50924. static readonly DISPLAY_LINES: number;
  50925. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  50926. static readonly DISPLAY_SPHERES: number;
  50927. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  50928. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  50929. /** If SkeletonViewer scene scope. */
  50930. private _scene;
  50931. /** Gets or sets the color used to render the skeleton */
  50932. color: Color3;
  50933. /** Array of the points of the skeleton fo the line view. */
  50934. private _debugLines;
  50935. /** The SkeletonViewers Mesh. */
  50936. private _debugMesh;
  50937. /** If SkeletonViewer is enabled. */
  50938. private _isEnabled;
  50939. /** If SkeletonViewer is ready. */
  50940. private _ready;
  50941. /** SkeletonViewer render observable. */
  50942. private _obs;
  50943. /** The Utility Layer to render the gizmos in. */
  50944. private _utilityLayer;
  50945. /** Gets the Scene. */
  50946. get scene(): Scene;
  50947. /** Gets the utilityLayer. */
  50948. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  50949. /** Checks Ready Status. */
  50950. get isReady(): Boolean;
  50951. /** Sets Ready Status. */
  50952. set ready(value: boolean);
  50953. /** Gets the debugMesh */
  50954. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  50955. /** Sets the debugMesh */
  50956. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  50957. /** Gets the material */
  50958. get material(): StandardMaterial;
  50959. /** Sets the material */
  50960. set material(value: StandardMaterial);
  50961. /**
  50962. * Creates a new SkeletonViewer
  50963. * @param skeleton defines the skeleton to render
  50964. * @param mesh defines the mesh attached to the skeleton
  50965. * @param scene defines the hosting scene
  50966. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50967. * @param renderingGroupId defines the rendering group id to use with the viewer
  50968. * @param options All of the extra constructor options for the SkeletonViewer
  50969. */
  50970. constructor(
  50971. /** defines the skeleton to render */
  50972. skeleton: Skeleton,
  50973. /** defines the mesh attached to the skeleton */
  50974. mesh: AbstractMesh,
  50975. /** The Scene scope*/
  50976. scene: Scene,
  50977. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50978. autoUpdateBonesMatrices?: boolean,
  50979. /** defines the rendering group id to use with the viewer */
  50980. renderingGroupId?: number,
  50981. /** is the options for the viewer */
  50982. options?: Partial<ISkeletonViewerOptions>);
  50983. /** The Dynamic bindings for the update functions */
  50984. private _bindObs;
  50985. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  50986. update(): void;
  50987. /** Gets or sets a boolean indicating if the viewer is enabled */
  50988. set isEnabled(value: boolean);
  50989. get isEnabled(): boolean;
  50990. private _getBonePosition;
  50991. private _getLinesForBonesWithLength;
  50992. private _getLinesForBonesNoLength;
  50993. /** function to revert the mesh and scene back to the initial state. */
  50994. private _revert;
  50995. /** function to build and bind sphere joint points and spur bone representations. */
  50996. private _buildSpheresAndSpurs;
  50997. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  50998. private _displayLinesUpdate;
  50999. /** Release associated resources */
  51000. dispose(): void;
  51001. }
  51002. }
  51003. declare module BABYLON {
  51004. /**
  51005. * Enum for Device Types
  51006. */
  51007. export enum DeviceType {
  51008. /** Generic */
  51009. Generic = 0,
  51010. /** Keyboard */
  51011. Keyboard = 1,
  51012. /** Mouse */
  51013. Mouse = 2,
  51014. /** Touch Pointers */
  51015. Touch = 3,
  51016. /** PS4 Dual Shock */
  51017. DualShock = 4,
  51018. /** Xbox */
  51019. Xbox = 5,
  51020. /** Switch Controller */
  51021. Switch = 6
  51022. }
  51023. /**
  51024. * Enum for All Pointers (Touch/Mouse)
  51025. */
  51026. export enum PointerInput {
  51027. /** Horizontal Axis */
  51028. Horizontal = 0,
  51029. /** Vertical Axis */
  51030. Vertical = 1,
  51031. /** Left Click or Touch */
  51032. LeftClick = 2,
  51033. /** Middle Click */
  51034. MiddleClick = 3,
  51035. /** Right Click */
  51036. RightClick = 4,
  51037. /** Browser Back */
  51038. BrowserBack = 5,
  51039. /** Browser Forward */
  51040. BrowserForward = 6
  51041. }
  51042. /**
  51043. * Enum for Dual Shock Gamepad
  51044. */
  51045. export enum DualShockInput {
  51046. /** Cross */
  51047. Cross = 0,
  51048. /** Circle */
  51049. Circle = 1,
  51050. /** Square */
  51051. Square = 2,
  51052. /** Triangle */
  51053. Triangle = 3,
  51054. /** L1 */
  51055. L1 = 4,
  51056. /** R1 */
  51057. R1 = 5,
  51058. /** L2 */
  51059. L2 = 6,
  51060. /** R2 */
  51061. R2 = 7,
  51062. /** Share */
  51063. Share = 8,
  51064. /** Options */
  51065. Options = 9,
  51066. /** L3 */
  51067. L3 = 10,
  51068. /** R3 */
  51069. R3 = 11,
  51070. /** DPadUp */
  51071. DPadUp = 12,
  51072. /** DPadDown */
  51073. DPadDown = 13,
  51074. /** DPadLeft */
  51075. DPadLeft = 14,
  51076. /** DRight */
  51077. DPadRight = 15,
  51078. /** Home */
  51079. Home = 16,
  51080. /** TouchPad */
  51081. TouchPad = 17,
  51082. /** LStickXAxis */
  51083. LStickXAxis = 18,
  51084. /** LStickYAxis */
  51085. LStickYAxis = 19,
  51086. /** RStickXAxis */
  51087. RStickXAxis = 20,
  51088. /** RStickYAxis */
  51089. RStickYAxis = 21
  51090. }
  51091. /**
  51092. * Enum for Xbox Gamepad
  51093. */
  51094. export enum XboxInput {
  51095. /** A */
  51096. A = 0,
  51097. /** B */
  51098. B = 1,
  51099. /** X */
  51100. X = 2,
  51101. /** Y */
  51102. Y = 3,
  51103. /** LB */
  51104. LB = 4,
  51105. /** RB */
  51106. RB = 5,
  51107. /** LT */
  51108. LT = 6,
  51109. /** RT */
  51110. RT = 7,
  51111. /** Back */
  51112. Back = 8,
  51113. /** Start */
  51114. Start = 9,
  51115. /** LS */
  51116. LS = 10,
  51117. /** RS */
  51118. RS = 11,
  51119. /** DPadUp */
  51120. DPadUp = 12,
  51121. /** DPadDown */
  51122. DPadDown = 13,
  51123. /** DPadLeft */
  51124. DPadLeft = 14,
  51125. /** DRight */
  51126. DPadRight = 15,
  51127. /** Home */
  51128. Home = 16,
  51129. /** LStickXAxis */
  51130. LStickXAxis = 17,
  51131. /** LStickYAxis */
  51132. LStickYAxis = 18,
  51133. /** RStickXAxis */
  51134. RStickXAxis = 19,
  51135. /** RStickYAxis */
  51136. RStickYAxis = 20
  51137. }
  51138. /**
  51139. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51140. */
  51141. export enum SwitchInput {
  51142. /** B */
  51143. B = 0,
  51144. /** A */
  51145. A = 1,
  51146. /** Y */
  51147. Y = 2,
  51148. /** X */
  51149. X = 3,
  51150. /** L */
  51151. L = 4,
  51152. /** R */
  51153. R = 5,
  51154. /** ZL */
  51155. ZL = 6,
  51156. /** ZR */
  51157. ZR = 7,
  51158. /** Minus */
  51159. Minus = 8,
  51160. /** Plus */
  51161. Plus = 9,
  51162. /** LS */
  51163. LS = 10,
  51164. /** RS */
  51165. RS = 11,
  51166. /** DPadUp */
  51167. DPadUp = 12,
  51168. /** DPadDown */
  51169. DPadDown = 13,
  51170. /** DPadLeft */
  51171. DPadLeft = 14,
  51172. /** DRight */
  51173. DPadRight = 15,
  51174. /** Home */
  51175. Home = 16,
  51176. /** Capture */
  51177. Capture = 17,
  51178. /** LStickXAxis */
  51179. LStickXAxis = 18,
  51180. /** LStickYAxis */
  51181. LStickYAxis = 19,
  51182. /** RStickXAxis */
  51183. RStickXAxis = 20,
  51184. /** RStickYAxis */
  51185. RStickYAxis = 21
  51186. }
  51187. }
  51188. declare module BABYLON {
  51189. /**
  51190. * This class will take all inputs from Keyboard, Pointer, and
  51191. * any Gamepads and provide a polling system that all devices
  51192. * will use. This class assumes that there will only be one
  51193. * pointer device and one keyboard.
  51194. */
  51195. export class DeviceInputSystem implements IDisposable {
  51196. /**
  51197. * Callback to be triggered when a device is connected
  51198. */
  51199. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51200. /**
  51201. * Callback to be triggered when a device is disconnected
  51202. */
  51203. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51204. /**
  51205. * Callback to be triggered when event driven input is updated
  51206. */
  51207. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51208. private _inputs;
  51209. private _gamepads;
  51210. private _keyboardActive;
  51211. private _pointerActive;
  51212. private _elementToAttachTo;
  51213. private _keyboardDownEvent;
  51214. private _keyboardUpEvent;
  51215. private _pointerMoveEvent;
  51216. private _pointerDownEvent;
  51217. private _pointerUpEvent;
  51218. private _gamepadConnectedEvent;
  51219. private _gamepadDisconnectedEvent;
  51220. private static _MAX_KEYCODES;
  51221. private static _MAX_POINTER_INPUTS;
  51222. private constructor();
  51223. /**
  51224. * Creates a new DeviceInputSystem instance
  51225. * @param engine Engine to pull input element from
  51226. * @returns The new instance
  51227. */
  51228. static Create(engine: Engine): DeviceInputSystem;
  51229. /**
  51230. * Checks for current device input value, given an id and input index
  51231. * @param deviceName Id of connected device
  51232. * @param inputIndex Index of device input
  51233. * @returns Current value of input
  51234. */
  51235. /**
  51236. * Checks for current device input value, given an id and input index
  51237. * @param deviceType Enum specifiying device type
  51238. * @param deviceSlot "Slot" or index that device is referenced in
  51239. * @param inputIndex Id of input to be checked
  51240. * @returns Current value of input
  51241. */
  51242. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51243. /**
  51244. * Dispose of all the eventlisteners
  51245. */
  51246. dispose(): void;
  51247. /**
  51248. * Add device and inputs to device array
  51249. * @param deviceType Enum specifiying device type
  51250. * @param deviceSlot "Slot" or index that device is referenced in
  51251. * @param numberOfInputs Number of input entries to create for given device
  51252. */
  51253. private _registerDevice;
  51254. /**
  51255. * Given a specific device name, remove that device from the device map
  51256. * @param deviceType Enum specifiying device type
  51257. * @param deviceSlot "Slot" or index that device is referenced in
  51258. */
  51259. private _unregisterDevice;
  51260. /**
  51261. * Handle all actions that come from keyboard interaction
  51262. */
  51263. private _handleKeyActions;
  51264. /**
  51265. * Handle all actions that come from pointer interaction
  51266. */
  51267. private _handlePointerActions;
  51268. /**
  51269. * Handle all actions that come from gamepad interaction
  51270. */
  51271. private _handleGamepadActions;
  51272. /**
  51273. * Update all non-event based devices with each frame
  51274. * @param deviceType Enum specifiying device type
  51275. * @param deviceSlot "Slot" or index that device is referenced in
  51276. * @param inputIndex Id of input to be checked
  51277. */
  51278. private _updateDevice;
  51279. /**
  51280. * Gets DeviceType from the device name
  51281. * @param deviceName Name of Device from DeviceInputSystem
  51282. * @returns DeviceType enum value
  51283. */
  51284. private _getGamepadDeviceType;
  51285. }
  51286. }
  51287. declare module BABYLON {
  51288. /**
  51289. * Type to handle enforcement of inputs
  51290. */
  51291. 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;
  51292. }
  51293. declare module BABYLON {
  51294. /**
  51295. * Class that handles all input for a specific device
  51296. */
  51297. export class DeviceSource<T extends DeviceType> {
  51298. /** Type of device */
  51299. readonly deviceType: DeviceType;
  51300. /** "Slot" or index that device is referenced in */
  51301. readonly deviceSlot: number;
  51302. /**
  51303. * Observable to handle device input changes per device
  51304. */
  51305. readonly onInputChangedObservable: Observable<{
  51306. inputIndex: DeviceInput<T>;
  51307. previousState: Nullable<number>;
  51308. currentState: Nullable<number>;
  51309. }>;
  51310. private readonly _deviceInputSystem;
  51311. /**
  51312. * Default Constructor
  51313. * @param deviceInputSystem Reference to DeviceInputSystem
  51314. * @param deviceType Type of device
  51315. * @param deviceSlot "Slot" or index that device is referenced in
  51316. */
  51317. constructor(deviceInputSystem: DeviceInputSystem,
  51318. /** Type of device */
  51319. deviceType: DeviceType,
  51320. /** "Slot" or index that device is referenced in */
  51321. deviceSlot?: number);
  51322. /**
  51323. * Get input for specific input
  51324. * @param inputIndex index of specific input on device
  51325. * @returns Input value from DeviceInputSystem
  51326. */
  51327. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51328. }
  51329. /**
  51330. * Class to keep track of devices
  51331. */
  51332. export class DeviceSourceManager implements IDisposable {
  51333. /**
  51334. * Observable to be triggered when before a device is connected
  51335. */
  51336. readonly onBeforeDeviceConnectedObservable: Observable<{
  51337. deviceType: DeviceType;
  51338. deviceSlot: number;
  51339. }>;
  51340. /**
  51341. * Observable to be triggered when before a device is disconnected
  51342. */
  51343. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51344. deviceType: DeviceType;
  51345. deviceSlot: number;
  51346. }>;
  51347. /**
  51348. * Observable to be triggered when after a device is connected
  51349. */
  51350. readonly onAfterDeviceConnectedObservable: Observable<{
  51351. deviceType: DeviceType;
  51352. deviceSlot: number;
  51353. }>;
  51354. /**
  51355. * Observable to be triggered when after a device is disconnected
  51356. */
  51357. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51358. deviceType: DeviceType;
  51359. deviceSlot: number;
  51360. }>;
  51361. private readonly _devices;
  51362. private readonly _firstDevice;
  51363. private readonly _deviceInputSystem;
  51364. /**
  51365. * Default Constructor
  51366. * @param engine engine to pull input element from
  51367. */
  51368. constructor(engine: Engine);
  51369. /**
  51370. * Gets a DeviceSource, given a type and slot
  51371. * @param deviceType Enum specifying device type
  51372. * @param deviceSlot "Slot" or index that device is referenced in
  51373. * @returns DeviceSource object
  51374. */
  51375. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51376. /**
  51377. * Gets an array of DeviceSource objects for a given device type
  51378. * @param deviceType Enum specifying device type
  51379. * @returns Array of DeviceSource objects
  51380. */
  51381. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51382. /**
  51383. * Dispose of DeviceInputSystem and other parts
  51384. */
  51385. dispose(): void;
  51386. /**
  51387. * Function to add device name to device list
  51388. * @param deviceType Enum specifying device type
  51389. * @param deviceSlot "Slot" or index that device is referenced in
  51390. */
  51391. private _addDevice;
  51392. /**
  51393. * Function to remove device name to device list
  51394. * @param deviceType Enum specifying device type
  51395. * @param deviceSlot "Slot" or index that device is referenced in
  51396. */
  51397. private _removeDevice;
  51398. /**
  51399. * Updates array storing first connected device of each type
  51400. * @param type Type of Device
  51401. */
  51402. private _updateFirstDevices;
  51403. }
  51404. }
  51405. declare module BABYLON {
  51406. /**
  51407. * Options to create the null engine
  51408. */
  51409. export class NullEngineOptions {
  51410. /**
  51411. * Render width (Default: 512)
  51412. */
  51413. renderWidth: number;
  51414. /**
  51415. * Render height (Default: 256)
  51416. */
  51417. renderHeight: number;
  51418. /**
  51419. * Texture size (Default: 512)
  51420. */
  51421. textureSize: number;
  51422. /**
  51423. * If delta time between frames should be constant
  51424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51425. */
  51426. deterministicLockstep: boolean;
  51427. /**
  51428. * Maximum about of steps between frames (Default: 4)
  51429. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51430. */
  51431. lockstepMaxSteps: number;
  51432. /**
  51433. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51434. */
  51435. useHighPrecisionMatrix?: boolean;
  51436. }
  51437. /**
  51438. * The null engine class provides support for headless version of babylon.js.
  51439. * This can be used in server side scenario or for testing purposes
  51440. */
  51441. export class NullEngine extends Engine {
  51442. private _options;
  51443. /**
  51444. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51446. * @returns true if engine is in deterministic lock step mode
  51447. */
  51448. isDeterministicLockStep(): boolean;
  51449. /**
  51450. * Gets the max steps when engine is running in deterministic lock step
  51451. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51452. * @returns the max steps
  51453. */
  51454. getLockstepMaxSteps(): number;
  51455. /**
  51456. * Gets the current hardware scaling level.
  51457. * By default the hardware scaling level is computed from the window device ratio.
  51458. * 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.
  51459. * @returns a number indicating the current hardware scaling level
  51460. */
  51461. getHardwareScalingLevel(): number;
  51462. constructor(options?: NullEngineOptions);
  51463. /**
  51464. * Creates a vertex buffer
  51465. * @param vertices the data for the vertex buffer
  51466. * @returns the new WebGL static buffer
  51467. */
  51468. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51469. /**
  51470. * Creates a new index buffer
  51471. * @param indices defines the content of the index buffer
  51472. * @param updatable defines if the index buffer must be updatable
  51473. * @returns a new webGL buffer
  51474. */
  51475. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51476. /**
  51477. * Clear the current render buffer or the current render target (if any is set up)
  51478. * @param color defines the color to use
  51479. * @param backBuffer defines if the back buffer must be cleared
  51480. * @param depth defines if the depth buffer must be cleared
  51481. * @param stencil defines if the stencil buffer must be cleared
  51482. */
  51483. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51484. /**
  51485. * Gets the current render width
  51486. * @param useScreen defines if screen size must be used (or the current render target if any)
  51487. * @returns a number defining the current render width
  51488. */
  51489. getRenderWidth(useScreen?: boolean): number;
  51490. /**
  51491. * Gets the current render height
  51492. * @param useScreen defines if screen size must be used (or the current render target if any)
  51493. * @returns a number defining the current render height
  51494. */
  51495. getRenderHeight(useScreen?: boolean): number;
  51496. /**
  51497. * Set the WebGL's viewport
  51498. * @param viewport defines the viewport element to be used
  51499. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51500. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51501. */
  51502. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51503. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51504. /**
  51505. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51506. * @param pipelineContext defines the pipeline context to use
  51507. * @param uniformsNames defines the list of uniform names
  51508. * @returns an array of webGL uniform locations
  51509. */
  51510. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51511. /**
  51512. * Gets the lsit of active attributes for a given webGL program
  51513. * @param pipelineContext defines the pipeline context to use
  51514. * @param attributesNames defines the list of attribute names to get
  51515. * @returns an array of indices indicating the offset of each attribute
  51516. */
  51517. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51518. /**
  51519. * Binds an effect to the webGL context
  51520. * @param effect defines the effect to bind
  51521. */
  51522. bindSamplers(effect: Effect): void;
  51523. /**
  51524. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51525. * @param effect defines the effect to activate
  51526. */
  51527. enableEffect(effect: Effect): void;
  51528. /**
  51529. * Set various states to the webGL context
  51530. * @param culling defines backface culling state
  51531. * @param zOffset defines the value to apply to zOffset (0 by default)
  51532. * @param force defines if states must be applied even if cache is up to date
  51533. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51534. */
  51535. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51536. /**
  51537. * Set the value of an uniform to an array of int32
  51538. * @param uniform defines the webGL uniform location where to store the value
  51539. * @param array defines the array of int32 to store
  51540. */
  51541. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51542. /**
  51543. * Set the value of an uniform to an array of int32 (stored as vec2)
  51544. * @param uniform defines the webGL uniform location where to store the value
  51545. * @param array defines the array of int32 to store
  51546. */
  51547. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51548. /**
  51549. * Set the value of an uniform to an array of int32 (stored as vec3)
  51550. * @param uniform defines the webGL uniform location where to store the value
  51551. * @param array defines the array of int32 to store
  51552. */
  51553. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51554. /**
  51555. * Set the value of an uniform to an array of int32 (stored as vec4)
  51556. * @param uniform defines the webGL uniform location where to store the value
  51557. * @param array defines the array of int32 to store
  51558. */
  51559. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51560. /**
  51561. * Set the value of an uniform to an array of float32
  51562. * @param uniform defines the webGL uniform location where to store the value
  51563. * @param array defines the array of float32 to store
  51564. */
  51565. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51566. /**
  51567. * Set the value of an uniform to an array of float32 (stored as vec2)
  51568. * @param uniform defines the webGL uniform location where to store the value
  51569. * @param array defines the array of float32 to store
  51570. */
  51571. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51572. /**
  51573. * Set the value of an uniform to an array of float32 (stored as vec3)
  51574. * @param uniform defines the webGL uniform location where to store the value
  51575. * @param array defines the array of float32 to store
  51576. */
  51577. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51578. /**
  51579. * Set the value of an uniform to an array of float32 (stored as vec4)
  51580. * @param uniform defines the webGL uniform location where to store the value
  51581. * @param array defines the array of float32 to store
  51582. */
  51583. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51584. /**
  51585. * Set the value of an uniform to an array of number
  51586. * @param uniform defines the webGL uniform location where to store the value
  51587. * @param array defines the array of number to store
  51588. */
  51589. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51590. /**
  51591. * Set the value of an uniform to an array of number (stored as vec2)
  51592. * @param uniform defines the webGL uniform location where to store the value
  51593. * @param array defines the array of number to store
  51594. */
  51595. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51596. /**
  51597. * Set the value of an uniform to an array of number (stored as vec3)
  51598. * @param uniform defines the webGL uniform location where to store the value
  51599. * @param array defines the array of number to store
  51600. */
  51601. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51602. /**
  51603. * Set the value of an uniform to an array of number (stored as vec4)
  51604. * @param uniform defines the webGL uniform location where to store the value
  51605. * @param array defines the array of number to store
  51606. */
  51607. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51608. /**
  51609. * Set the value of an uniform to an array of float32 (stored as matrices)
  51610. * @param uniform defines the webGL uniform location where to store the value
  51611. * @param matrices defines the array of float32 to store
  51612. */
  51613. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51614. /**
  51615. * Set the value of an uniform to a matrix (3x3)
  51616. * @param uniform defines the webGL uniform location where to store the value
  51617. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51618. */
  51619. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51620. /**
  51621. * Set the value of an uniform to a matrix (2x2)
  51622. * @param uniform defines the webGL uniform location where to store the value
  51623. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51624. */
  51625. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51626. /**
  51627. * Set the value of an uniform to a number (float)
  51628. * @param uniform defines the webGL uniform location where to store the value
  51629. * @param value defines the float number to store
  51630. */
  51631. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51632. /**
  51633. * Set the value of an uniform to a vec2
  51634. * @param uniform defines the webGL uniform location where to store the value
  51635. * @param x defines the 1st component of the value
  51636. * @param y defines the 2nd component of the value
  51637. */
  51638. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51639. /**
  51640. * Set the value of an uniform to a vec3
  51641. * @param uniform defines the webGL uniform location where to store the value
  51642. * @param x defines the 1st component of the value
  51643. * @param y defines the 2nd component of the value
  51644. * @param z defines the 3rd component of the value
  51645. */
  51646. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51647. /**
  51648. * Set the value of an uniform to a boolean
  51649. * @param uniform defines the webGL uniform location where to store the value
  51650. * @param bool defines the boolean to store
  51651. */
  51652. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51653. /**
  51654. * Set the value of an uniform to a vec4
  51655. * @param uniform defines the webGL uniform location where to store the value
  51656. * @param x defines the 1st component of the value
  51657. * @param y defines the 2nd component of the value
  51658. * @param z defines the 3rd component of the value
  51659. * @param w defines the 4th component of the value
  51660. */
  51661. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51662. /**
  51663. * Sets the current alpha mode
  51664. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51665. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51666. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51667. */
  51668. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51669. /**
  51670. * Bind webGl buffers directly to the webGL context
  51671. * @param vertexBuffers defines the vertex buffer to bind
  51672. * @param indexBuffer defines the index buffer to bind
  51673. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51674. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51675. * @param effect defines the effect associated with the vertex buffer
  51676. */
  51677. bindBuffers(vertexBuffers: {
  51678. [key: string]: VertexBuffer;
  51679. }, indexBuffer: DataBuffer, effect: Effect): void;
  51680. /**
  51681. * Force the entire cache to be cleared
  51682. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51683. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51684. */
  51685. wipeCaches(bruteForce?: boolean): void;
  51686. /**
  51687. * Send a draw order
  51688. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51689. * @param indexStart defines the starting index
  51690. * @param indexCount defines the number of index to draw
  51691. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51692. */
  51693. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51694. /**
  51695. * Draw a list of indexed primitives
  51696. * @param fillMode defines the primitive to use
  51697. * @param indexStart defines the starting index
  51698. * @param indexCount defines the number of index to draw
  51699. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51700. */
  51701. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51702. /**
  51703. * Draw a list of unindexed primitives
  51704. * @param fillMode defines the primitive to use
  51705. * @param verticesStart defines the index of first vertex to draw
  51706. * @param verticesCount defines the count of vertices to draw
  51707. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51708. */
  51709. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51710. /** @hidden */
  51711. _createTexture(): WebGLTexture;
  51712. /** @hidden */
  51713. _releaseTexture(texture: InternalTexture): void;
  51714. /**
  51715. * Usually called from Texture.ts.
  51716. * Passed information to create a WebGLTexture
  51717. * @param urlArg defines a value which contains one of the following:
  51718. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51719. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51720. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51721. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51722. * @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)
  51723. * @param scene needed for loading to the correct scene
  51724. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51725. * @param onLoad optional callback to be called upon successful completion
  51726. * @param onError optional callback to be called upon failure
  51727. * @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
  51728. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51729. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51730. * @param forcedExtension defines the extension to use to pick the right loader
  51731. * @param mimeType defines an optional mime type
  51732. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51733. */
  51734. 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;
  51735. /**
  51736. * Creates a new render target texture
  51737. * @param size defines the size of the texture
  51738. * @param options defines the options used to create the texture
  51739. * @returns a new render target texture stored in an InternalTexture
  51740. */
  51741. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51742. /**
  51743. * Update the sampling mode of a given texture
  51744. * @param samplingMode defines the required sampling mode
  51745. * @param texture defines the texture to update
  51746. */
  51747. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51748. /**
  51749. * Binds the frame buffer to the specified texture.
  51750. * @param texture The texture to render to or null for the default canvas
  51751. * @param faceIndex The face of the texture to render to in case of cube texture
  51752. * @param requiredWidth The width of the target to render to
  51753. * @param requiredHeight The height of the target to render to
  51754. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51755. * @param lodLevel defines le lod level to bind to the frame buffer
  51756. */
  51757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51758. /**
  51759. * Unbind the current render target texture from the webGL context
  51760. * @param texture defines the render target texture to unbind
  51761. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51762. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51763. */
  51764. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51765. /**
  51766. * Creates a dynamic vertex buffer
  51767. * @param vertices the data for the dynamic vertex buffer
  51768. * @returns the new WebGL dynamic buffer
  51769. */
  51770. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51771. /**
  51772. * Update the content of a dynamic texture
  51773. * @param texture defines the texture to update
  51774. * @param canvas defines the canvas containing the source
  51775. * @param invertY defines if data must be stored with Y axis inverted
  51776. * @param premulAlpha defines if alpha is stored as premultiplied
  51777. * @param format defines the format of the data
  51778. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51779. */
  51780. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51781. /**
  51782. * Gets a boolean indicating if all created effects are ready
  51783. * @returns true if all effects are ready
  51784. */
  51785. areAllEffectsReady(): boolean;
  51786. /**
  51787. * @hidden
  51788. * Get the current error code of the webGL context
  51789. * @returns the error code
  51790. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51791. */
  51792. getError(): number;
  51793. /** @hidden */
  51794. _getUnpackAlignement(): number;
  51795. /** @hidden */
  51796. _unpackFlipY(value: boolean): void;
  51797. /**
  51798. * Update a dynamic index buffer
  51799. * @param indexBuffer defines the target index buffer
  51800. * @param indices defines the data to update
  51801. * @param offset defines the offset in the target index buffer where update should start
  51802. */
  51803. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51804. /**
  51805. * Updates a dynamic vertex buffer.
  51806. * @param vertexBuffer the vertex buffer to update
  51807. * @param vertices the data used to update the vertex buffer
  51808. * @param byteOffset the byte offset of the data (optional)
  51809. * @param byteLength the byte length of the data (optional)
  51810. */
  51811. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51812. /** @hidden */
  51813. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51814. /** @hidden */
  51815. _bindTexture(channel: number, texture: InternalTexture): void;
  51816. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51817. /**
  51818. * 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
  51819. */
  51820. releaseEffects(): void;
  51821. displayLoadingUI(): void;
  51822. hideLoadingUI(): void;
  51823. /** @hidden */
  51824. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51825. /** @hidden */
  51826. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51827. /** @hidden */
  51828. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51829. /** @hidden */
  51830. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51831. }
  51832. }
  51833. declare module BABYLON {
  51834. /**
  51835. * @hidden
  51836. **/
  51837. export class _TimeToken {
  51838. _startTimeQuery: Nullable<WebGLQuery>;
  51839. _endTimeQuery: Nullable<WebGLQuery>;
  51840. _timeElapsedQuery: Nullable<WebGLQuery>;
  51841. _timeElapsedQueryEnded: boolean;
  51842. }
  51843. }
  51844. declare module BABYLON {
  51845. /** @hidden */
  51846. export class _OcclusionDataStorage {
  51847. /** @hidden */
  51848. occlusionInternalRetryCounter: number;
  51849. /** @hidden */
  51850. isOcclusionQueryInProgress: boolean;
  51851. /** @hidden */
  51852. isOccluded: boolean;
  51853. /** @hidden */
  51854. occlusionRetryCount: number;
  51855. /** @hidden */
  51856. occlusionType: number;
  51857. /** @hidden */
  51858. occlusionQueryAlgorithmType: number;
  51859. }
  51860. interface Engine {
  51861. /**
  51862. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51863. * @return the new query
  51864. */
  51865. createQuery(): WebGLQuery;
  51866. /**
  51867. * Delete and release a webGL query
  51868. * @param query defines the query to delete
  51869. * @return the current engine
  51870. */
  51871. deleteQuery(query: WebGLQuery): Engine;
  51872. /**
  51873. * Check if a given query has resolved and got its value
  51874. * @param query defines the query to check
  51875. * @returns true if the query got its value
  51876. */
  51877. isQueryResultAvailable(query: WebGLQuery): boolean;
  51878. /**
  51879. * Gets the value of a given query
  51880. * @param query defines the query to check
  51881. * @returns the value of the query
  51882. */
  51883. getQueryResult(query: WebGLQuery): number;
  51884. /**
  51885. * Initiates an occlusion query
  51886. * @param algorithmType defines the algorithm to use
  51887. * @param query defines the query to use
  51888. * @returns the current engine
  51889. * @see https://doc.babylonjs.com/features/occlusionquery
  51890. */
  51891. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51892. /**
  51893. * Ends an occlusion query
  51894. * @see https://doc.babylonjs.com/features/occlusionquery
  51895. * @param algorithmType defines the algorithm to use
  51896. * @returns the current engine
  51897. */
  51898. endOcclusionQuery(algorithmType: number): Engine;
  51899. /**
  51900. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51901. * Please note that only one query can be issued at a time
  51902. * @returns a time token used to track the time span
  51903. */
  51904. startTimeQuery(): Nullable<_TimeToken>;
  51905. /**
  51906. * Ends a time query
  51907. * @param token defines the token used to measure the time span
  51908. * @returns the time spent (in ns)
  51909. */
  51910. endTimeQuery(token: _TimeToken): int;
  51911. /** @hidden */
  51912. _currentNonTimestampToken: Nullable<_TimeToken>;
  51913. /** @hidden */
  51914. _createTimeQuery(): WebGLQuery;
  51915. /** @hidden */
  51916. _deleteTimeQuery(query: WebGLQuery): void;
  51917. /** @hidden */
  51918. _getGlAlgorithmType(algorithmType: number): number;
  51919. /** @hidden */
  51920. _getTimeQueryResult(query: WebGLQuery): any;
  51921. /** @hidden */
  51922. _getTimeQueryAvailability(query: WebGLQuery): any;
  51923. }
  51924. interface AbstractMesh {
  51925. /**
  51926. * Backing filed
  51927. * @hidden
  51928. */
  51929. __occlusionDataStorage: _OcclusionDataStorage;
  51930. /**
  51931. * Access property
  51932. * @hidden
  51933. */
  51934. _occlusionDataStorage: _OcclusionDataStorage;
  51935. /**
  51936. * 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.
  51937. * The default value is -1 which means don't break the query and wait till the result
  51938. * @see https://doc.babylonjs.com/features/occlusionquery
  51939. */
  51940. occlusionRetryCount: number;
  51941. /**
  51942. * 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:
  51943. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51944. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51945. * * 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.
  51946. * @see https://doc.babylonjs.com/features/occlusionquery
  51947. */
  51948. occlusionType: number;
  51949. /**
  51950. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51951. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51952. * * 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.
  51953. * @see https://doc.babylonjs.com/features/occlusionquery
  51954. */
  51955. occlusionQueryAlgorithmType: number;
  51956. /**
  51957. * 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
  51958. * @see https://doc.babylonjs.com/features/occlusionquery
  51959. */
  51960. isOccluded: boolean;
  51961. /**
  51962. * Flag to check the progress status of the query
  51963. * @see https://doc.babylonjs.com/features/occlusionquery
  51964. */
  51965. isOcclusionQueryInProgress: boolean;
  51966. }
  51967. }
  51968. declare module BABYLON {
  51969. /** @hidden */
  51970. export var _forceTransformFeedbackToBundle: boolean;
  51971. interface Engine {
  51972. /**
  51973. * Creates a webGL transform feedback object
  51974. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51975. * @returns the webGL transform feedback object
  51976. */
  51977. createTransformFeedback(): WebGLTransformFeedback;
  51978. /**
  51979. * Delete a webGL transform feedback object
  51980. * @param value defines the webGL transform feedback object to delete
  51981. */
  51982. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51983. /**
  51984. * Bind a webGL transform feedback object to the webgl context
  51985. * @param value defines the webGL transform feedback object to bind
  51986. */
  51987. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51988. /**
  51989. * Begins a transform feedback operation
  51990. * @param usePoints defines if points or triangles must be used
  51991. */
  51992. beginTransformFeedback(usePoints: boolean): void;
  51993. /**
  51994. * Ends a transform feedback operation
  51995. */
  51996. endTransformFeedback(): void;
  51997. /**
  51998. * Specify the varyings to use with transform feedback
  51999. * @param program defines the associated webGL program
  52000. * @param value defines the list of strings representing the varying names
  52001. */
  52002. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52003. /**
  52004. * Bind a webGL buffer for a transform feedback operation
  52005. * @param value defines the webGL buffer to bind
  52006. */
  52007. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52008. }
  52009. }
  52010. declare module BABYLON {
  52011. /**
  52012. * Class used to define an additional view for the engine
  52013. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52014. */
  52015. export class EngineView {
  52016. /** Defines the canvas where to render the view */
  52017. target: HTMLCanvasElement;
  52018. /** Defines an optional camera used to render the view (will use active camera else) */
  52019. camera?: Camera;
  52020. }
  52021. interface Engine {
  52022. /**
  52023. * Gets or sets the HTML element to use for attaching events
  52024. */
  52025. inputElement: Nullable<HTMLElement>;
  52026. /**
  52027. * Gets the current engine view
  52028. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52029. */
  52030. activeView: Nullable<EngineView>;
  52031. /** Gets or sets the list of views */
  52032. views: EngineView[];
  52033. /**
  52034. * Register a new child canvas
  52035. * @param canvas defines the canvas to register
  52036. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52037. * @returns the associated view
  52038. */
  52039. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52040. /**
  52041. * Remove a registered child canvas
  52042. * @param canvas defines the canvas to remove
  52043. * @returns the current engine
  52044. */
  52045. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52046. }
  52047. }
  52048. declare module BABYLON {
  52049. interface Engine {
  52050. /** @hidden */
  52051. _excludedCompressedTextures: string[];
  52052. /** @hidden */
  52053. _textureFormatInUse: string;
  52054. /**
  52055. * Gets the list of texture formats supported
  52056. */
  52057. readonly texturesSupported: Array<string>;
  52058. /**
  52059. * Gets the texture format in use
  52060. */
  52061. readonly textureFormatInUse: Nullable<string>;
  52062. /**
  52063. * Set the compressed texture extensions or file names to skip.
  52064. *
  52065. * @param skippedFiles defines the list of those texture files you want to skip
  52066. * Example: [".dds", ".env", "myfile.png"]
  52067. */
  52068. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52069. /**
  52070. * Set the compressed texture format to use, based on the formats you have, and the formats
  52071. * supported by the hardware / browser.
  52072. *
  52073. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52074. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52075. * to API arguments needed to compressed textures. This puts the burden on the container
  52076. * generator to house the arcane code for determining these for current & future formats.
  52077. *
  52078. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52079. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52080. *
  52081. * Note: The result of this call is not taken into account when a texture is base64.
  52082. *
  52083. * @param formatsAvailable defines the list of those format families you have created
  52084. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52085. *
  52086. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52087. * @returns The extension selected.
  52088. */
  52089. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52090. }
  52091. }
  52092. declare module BABYLON {
  52093. /**
  52094. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52095. */
  52096. export interface CubeMapInfo {
  52097. /**
  52098. * The pixel array for the front face.
  52099. * This is stored in format, left to right, up to down format.
  52100. */
  52101. front: Nullable<ArrayBufferView>;
  52102. /**
  52103. * The pixel array for the back face.
  52104. * This is stored in format, left to right, up to down format.
  52105. */
  52106. back: Nullable<ArrayBufferView>;
  52107. /**
  52108. * The pixel array for the left face.
  52109. * This is stored in format, left to right, up to down format.
  52110. */
  52111. left: Nullable<ArrayBufferView>;
  52112. /**
  52113. * The pixel array for the right face.
  52114. * This is stored in format, left to right, up to down format.
  52115. */
  52116. right: Nullable<ArrayBufferView>;
  52117. /**
  52118. * The pixel array for the up face.
  52119. * This is stored in format, left to right, up to down format.
  52120. */
  52121. up: Nullable<ArrayBufferView>;
  52122. /**
  52123. * The pixel array for the down face.
  52124. * This is stored in format, left to right, up to down format.
  52125. */
  52126. down: Nullable<ArrayBufferView>;
  52127. /**
  52128. * The size of the cubemap stored.
  52129. *
  52130. * Each faces will be size * size pixels.
  52131. */
  52132. size: number;
  52133. /**
  52134. * The format of the texture.
  52135. *
  52136. * RGBA, RGB.
  52137. */
  52138. format: number;
  52139. /**
  52140. * The type of the texture data.
  52141. *
  52142. * UNSIGNED_INT, FLOAT.
  52143. */
  52144. type: number;
  52145. /**
  52146. * Specifies whether the texture is in gamma space.
  52147. */
  52148. gammaSpace: boolean;
  52149. }
  52150. /**
  52151. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52152. */
  52153. export class PanoramaToCubeMapTools {
  52154. private static FACE_LEFT;
  52155. private static FACE_RIGHT;
  52156. private static FACE_FRONT;
  52157. private static FACE_BACK;
  52158. private static FACE_DOWN;
  52159. private static FACE_UP;
  52160. /**
  52161. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52162. *
  52163. * @param float32Array The source data.
  52164. * @param inputWidth The width of the input panorama.
  52165. * @param inputHeight The height of the input panorama.
  52166. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52167. * @return The cubemap data
  52168. */
  52169. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52170. private static CreateCubemapTexture;
  52171. private static CalcProjectionSpherical;
  52172. }
  52173. }
  52174. declare module BABYLON {
  52175. /**
  52176. * Helper class dealing with the extraction of spherical polynomial dataArray
  52177. * from a cube map.
  52178. */
  52179. export class CubeMapToSphericalPolynomialTools {
  52180. private static FileFaces;
  52181. /**
  52182. * Converts a texture to the according Spherical Polynomial data.
  52183. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52184. *
  52185. * @param texture The texture to extract the information from.
  52186. * @return The Spherical Polynomial data.
  52187. */
  52188. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52189. /**
  52190. * Converts a cubemap to the according Spherical Polynomial data.
  52191. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52192. *
  52193. * @param cubeInfo The Cube map to extract the information from.
  52194. * @return The Spherical Polynomial data.
  52195. */
  52196. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. interface BaseTexture {
  52201. /**
  52202. * Get the polynomial representation of the texture data.
  52203. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52204. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52205. */
  52206. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /** @hidden */
  52211. export var rgbdEncodePixelShader: {
  52212. name: string;
  52213. shader: string;
  52214. };
  52215. }
  52216. declare module BABYLON {
  52217. /** @hidden */
  52218. export var rgbdDecodePixelShader: {
  52219. name: string;
  52220. shader: string;
  52221. };
  52222. }
  52223. declare module BABYLON {
  52224. /**
  52225. * Raw texture data and descriptor sufficient for WebGL texture upload
  52226. */
  52227. export interface EnvironmentTextureInfo {
  52228. /**
  52229. * Version of the environment map
  52230. */
  52231. version: number;
  52232. /**
  52233. * Width of image
  52234. */
  52235. width: number;
  52236. /**
  52237. * Irradiance information stored in the file.
  52238. */
  52239. irradiance: any;
  52240. /**
  52241. * Specular information stored in the file.
  52242. */
  52243. specular: any;
  52244. }
  52245. /**
  52246. * Defines One Image in the file. It requires only the position in the file
  52247. * as well as the length.
  52248. */
  52249. interface BufferImageData {
  52250. /**
  52251. * Length of the image data.
  52252. */
  52253. length: number;
  52254. /**
  52255. * Position of the data from the null terminator delimiting the end of the JSON.
  52256. */
  52257. position: number;
  52258. }
  52259. /**
  52260. * Defines the specular data enclosed in the file.
  52261. * This corresponds to the version 1 of the data.
  52262. */
  52263. export interface EnvironmentTextureSpecularInfoV1 {
  52264. /**
  52265. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52266. */
  52267. specularDataPosition?: number;
  52268. /**
  52269. * This contains all the images data needed to reconstruct the cubemap.
  52270. */
  52271. mipmaps: Array<BufferImageData>;
  52272. /**
  52273. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52274. */
  52275. lodGenerationScale: number;
  52276. }
  52277. /**
  52278. * Sets of helpers addressing the serialization and deserialization of environment texture
  52279. * stored in a BabylonJS env file.
  52280. * Those files are usually stored as .env files.
  52281. */
  52282. export class EnvironmentTextureTools {
  52283. /**
  52284. * Magic number identifying the env file.
  52285. */
  52286. private static _MagicBytes;
  52287. /**
  52288. * Gets the environment info from an env file.
  52289. * @param data The array buffer containing the .env bytes.
  52290. * @returns the environment file info (the json header) if successfully parsed.
  52291. */
  52292. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52293. /**
  52294. * Creates an environment texture from a loaded cube texture.
  52295. * @param texture defines the cube texture to convert in env file
  52296. * @return a promise containing the environment data if succesfull.
  52297. */
  52298. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52299. /**
  52300. * Creates a JSON representation of the spherical data.
  52301. * @param texture defines the texture containing the polynomials
  52302. * @return the JSON representation of the spherical info
  52303. */
  52304. private static _CreateEnvTextureIrradiance;
  52305. /**
  52306. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52307. * @param data the image data
  52308. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52309. * @return the views described by info providing access to the underlying buffer
  52310. */
  52311. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52312. /**
  52313. * Uploads the texture info contained in the env file to the GPU.
  52314. * @param texture defines the internal texture to upload to
  52315. * @param data defines the data to load
  52316. * @param info defines the texture info retrieved through the GetEnvInfo method
  52317. * @returns a promise
  52318. */
  52319. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52320. private static _OnImageReadyAsync;
  52321. /**
  52322. * Uploads the levels of image data to the GPU.
  52323. * @param texture defines the internal texture to upload to
  52324. * @param imageData defines the array buffer views of image data [mipmap][face]
  52325. * @returns a promise
  52326. */
  52327. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52328. /**
  52329. * Uploads spherical polynomials information to the texture.
  52330. * @param texture defines the texture we are trying to upload the information to
  52331. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52332. */
  52333. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52334. /** @hidden */
  52335. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Class used to inline functions in shader code
  52341. */
  52342. export class ShaderCodeInliner {
  52343. private static readonly _RegexpFindFunctionNameAndType;
  52344. private _sourceCode;
  52345. private _functionDescr;
  52346. private _numMaxIterations;
  52347. /** Gets or sets the token used to mark the functions to inline */
  52348. inlineToken: string;
  52349. /** Gets or sets the debug mode */
  52350. debug: boolean;
  52351. /** Gets the code after the inlining process */
  52352. get code(): string;
  52353. /**
  52354. * Initializes the inliner
  52355. * @param sourceCode shader code source to inline
  52356. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52357. */
  52358. constructor(sourceCode: string, numMaxIterations?: number);
  52359. /**
  52360. * Start the processing of the shader code
  52361. */
  52362. processCode(): void;
  52363. private _collectFunctions;
  52364. private _processInlining;
  52365. private _extractBetweenMarkers;
  52366. private _skipWhitespaces;
  52367. private _removeComments;
  52368. private _replaceFunctionCallsByCode;
  52369. private _findBackward;
  52370. private _escapeRegExp;
  52371. private _replaceNames;
  52372. }
  52373. }
  52374. declare module BABYLON {
  52375. /**
  52376. * Container for accessors for natively-stored mesh data buffers.
  52377. */
  52378. class NativeDataBuffer extends DataBuffer {
  52379. /**
  52380. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52381. */
  52382. nativeIndexBuffer?: any;
  52383. /**
  52384. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52385. */
  52386. nativeVertexBuffer?: any;
  52387. }
  52388. /** @hidden */
  52389. class NativeTexture extends InternalTexture {
  52390. getInternalTexture(): InternalTexture;
  52391. getViewCount(): number;
  52392. }
  52393. /** @hidden */
  52394. export class NativeEngine extends Engine {
  52395. private readonly _native;
  52396. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52397. private readonly INVALID_HANDLE;
  52398. getHardwareScalingLevel(): number;
  52399. constructor();
  52400. dispose(): void;
  52401. /**
  52402. * Can be used to override the current requestAnimationFrame requester.
  52403. * @hidden
  52404. */
  52405. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52406. /**
  52407. * Override default engine behavior.
  52408. * @param color
  52409. * @param backBuffer
  52410. * @param depth
  52411. * @param stencil
  52412. */
  52413. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52414. /**
  52415. * Gets host document
  52416. * @returns the host document object
  52417. */
  52418. getHostDocument(): Nullable<Document>;
  52419. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52420. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52421. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52422. recordVertexArrayObject(vertexBuffers: {
  52423. [key: string]: VertexBuffer;
  52424. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52425. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52426. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52428. /**
  52429. * Draw a list of indexed primitives
  52430. * @param fillMode defines the primitive to use
  52431. * @param indexStart defines the starting index
  52432. * @param indexCount defines the number of index to draw
  52433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52434. */
  52435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52436. /**
  52437. * Draw a list of unindexed primitives
  52438. * @param fillMode defines the primitive to use
  52439. * @param verticesStart defines the index of first vertex to draw
  52440. * @param verticesCount defines the count of vertices to draw
  52441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52442. */
  52443. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52444. createPipelineContext(): IPipelineContext;
  52445. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52446. /** @hidden */
  52447. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52448. /** @hidden */
  52449. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52450. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52451. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52452. protected _setProgram(program: WebGLProgram): void;
  52453. _releaseEffect(effect: Effect): void;
  52454. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52455. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52456. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52457. bindSamplers(effect: Effect): void;
  52458. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52459. getRenderWidth(useScreen?: boolean): number;
  52460. getRenderHeight(useScreen?: boolean): number;
  52461. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52462. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52463. /**
  52464. * Set the z offset to apply to current rendering
  52465. * @param value defines the offset to apply
  52466. */
  52467. setZOffset(value: number): void;
  52468. /**
  52469. * Gets the current value of the zOffset
  52470. * @returns the current zOffset state
  52471. */
  52472. getZOffset(): number;
  52473. /**
  52474. * Enable or disable depth buffering
  52475. * @param enable defines the state to set
  52476. */
  52477. setDepthBuffer(enable: boolean): void;
  52478. /**
  52479. * Gets a boolean indicating if depth writing is enabled
  52480. * @returns the current depth writing state
  52481. */
  52482. getDepthWrite(): boolean;
  52483. /**
  52484. * Enable or disable depth writing
  52485. * @param enable defines the state to set
  52486. */
  52487. setDepthWrite(enable: boolean): void;
  52488. /**
  52489. * Enable or disable color writing
  52490. * @param enable defines the state to set
  52491. */
  52492. setColorWrite(enable: boolean): void;
  52493. /**
  52494. * Gets a boolean indicating if color writing is enabled
  52495. * @returns the current color writing state
  52496. */
  52497. getColorWrite(): boolean;
  52498. /**
  52499. * Sets alpha constants used by some alpha blending modes
  52500. * @param r defines the red component
  52501. * @param g defines the green component
  52502. * @param b defines the blue component
  52503. * @param a defines the alpha component
  52504. */
  52505. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52506. /**
  52507. * Sets the current alpha mode
  52508. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52509. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52510. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52511. */
  52512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52513. /**
  52514. * Gets the current alpha mode
  52515. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52516. * @returns the current alpha mode
  52517. */
  52518. getAlphaMode(): number;
  52519. setInt(uniform: WebGLUniformLocation, int: number): void;
  52520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52522. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52523. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52525. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52526. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52527. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52528. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52529. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52530. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52531. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52532. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52533. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52534. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52535. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52536. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52537. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52538. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52539. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52540. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52541. wipeCaches(bruteForce?: boolean): void;
  52542. _createTexture(): WebGLTexture;
  52543. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52544. /**
  52545. * Usually called from Texture.ts.
  52546. * Passed information to create a WebGLTexture
  52547. * @param url defines a value which contains one of the following:
  52548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52552. * @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)
  52553. * @param scene needed for loading to the correct scene
  52554. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52555. * @param onLoad optional callback to be called upon successful completion
  52556. * @param onError optional callback to be called upon failure
  52557. * @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
  52558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52560. * @param forcedExtension defines the extension to use to pick the right loader
  52561. * @param mimeType defines an optional mime type
  52562. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52563. */
  52564. 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): InternalTexture;
  52565. /**
  52566. * Creates a cube texture
  52567. * @param rootUrl defines the url where the files to load is located
  52568. * @param scene defines the current scene
  52569. * @param files defines the list of files to load (1 per face)
  52570. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52571. * @param onLoad defines an optional callback raised when the texture is loaded
  52572. * @param onError defines an optional callback raised if there is an issue to load the texture
  52573. * @param format defines the format of the data
  52574. * @param forcedExtension defines the extension to use to pick the right loader
  52575. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52576. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52577. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52578. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52579. * @returns the cube texture as an InternalTexture
  52580. */
  52581. 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;
  52582. private _getSamplingFilter;
  52583. private static _GetNativeTextureFormat;
  52584. createRenderTargetTexture(size: number | {
  52585. width: number;
  52586. height: number;
  52587. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52588. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52589. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52590. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52591. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52592. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52593. /**
  52594. * Updates a dynamic vertex buffer.
  52595. * @param vertexBuffer the vertex buffer to update
  52596. * @param data the data used to update the vertex buffer
  52597. * @param byteOffset the byte offset of the data (optional)
  52598. * @param byteLength the byte length of the data (optional)
  52599. */
  52600. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52601. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52602. private _updateAnisotropicLevel;
  52603. private _getAddressMode;
  52604. /** @hidden */
  52605. _bindTexture(channel: number, texture: InternalTexture): void;
  52606. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52607. releaseEffects(): void;
  52608. /** @hidden */
  52609. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52610. /** @hidden */
  52611. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52612. /** @hidden */
  52613. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52614. /** @hidden */
  52615. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52616. }
  52617. }
  52618. declare module BABYLON {
  52619. /**
  52620. * Gather the list of clipboard event types as constants.
  52621. */
  52622. export class ClipboardEventTypes {
  52623. /**
  52624. * The clipboard event is fired when a copy command is active (pressed).
  52625. */
  52626. static readonly COPY: number;
  52627. /**
  52628. * The clipboard event is fired when a cut command is active (pressed).
  52629. */
  52630. static readonly CUT: number;
  52631. /**
  52632. * The clipboard event is fired when a paste command is active (pressed).
  52633. */
  52634. static readonly PASTE: number;
  52635. }
  52636. /**
  52637. * This class is used to store clipboard related info for the onClipboardObservable event.
  52638. */
  52639. export class ClipboardInfo {
  52640. /**
  52641. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52642. */
  52643. type: number;
  52644. /**
  52645. * Defines the related dom event
  52646. */
  52647. event: ClipboardEvent;
  52648. /**
  52649. *Creates an instance of ClipboardInfo.
  52650. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52651. * @param event Defines the related dom event
  52652. */
  52653. constructor(
  52654. /**
  52655. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52656. */
  52657. type: number,
  52658. /**
  52659. * Defines the related dom event
  52660. */
  52661. event: ClipboardEvent);
  52662. /**
  52663. * Get the clipboard event's type from the keycode.
  52664. * @param keyCode Defines the keyCode for the current keyboard event.
  52665. * @return {number}
  52666. */
  52667. static GetTypeFromCharacter(keyCode: number): number;
  52668. }
  52669. }
  52670. declare module BABYLON {
  52671. /**
  52672. * Google Daydream controller
  52673. */
  52674. export class DaydreamController extends WebVRController {
  52675. /**
  52676. * Base Url for the controller model.
  52677. */
  52678. static MODEL_BASE_URL: string;
  52679. /**
  52680. * File name for the controller model.
  52681. */
  52682. static MODEL_FILENAME: string;
  52683. /**
  52684. * Gamepad Id prefix used to identify Daydream Controller.
  52685. */
  52686. static readonly GAMEPAD_ID_PREFIX: string;
  52687. /**
  52688. * Creates a new DaydreamController from a gamepad
  52689. * @param vrGamepad the gamepad that the controller should be created from
  52690. */
  52691. constructor(vrGamepad: any);
  52692. /**
  52693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52694. * @param scene scene in which to add meshes
  52695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52696. */
  52697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52698. /**
  52699. * Called once for each button that changed state since the last frame
  52700. * @param buttonIdx Which button index changed
  52701. * @param state New state of the button
  52702. * @param changes Which properties on the state changed since last frame
  52703. */
  52704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * Gear VR Controller
  52710. */
  52711. export class GearVRController extends WebVRController {
  52712. /**
  52713. * Base Url for the controller model.
  52714. */
  52715. static MODEL_BASE_URL: string;
  52716. /**
  52717. * File name for the controller model.
  52718. */
  52719. static MODEL_FILENAME: string;
  52720. /**
  52721. * Gamepad Id prefix used to identify this controller.
  52722. */
  52723. static readonly GAMEPAD_ID_PREFIX: string;
  52724. private readonly _buttonIndexToObservableNameMap;
  52725. /**
  52726. * Creates a new GearVRController from a gamepad
  52727. * @param vrGamepad the gamepad that the controller should be created from
  52728. */
  52729. constructor(vrGamepad: any);
  52730. /**
  52731. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52732. * @param scene scene in which to add meshes
  52733. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52734. */
  52735. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52736. /**
  52737. * Called once for each button that changed state since the last frame
  52738. * @param buttonIdx Which button index changed
  52739. * @param state New state of the button
  52740. * @param changes Which properties on the state changed since last frame
  52741. */
  52742. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52743. }
  52744. }
  52745. declare module BABYLON {
  52746. /**
  52747. * Generic Controller
  52748. */
  52749. export class GenericController extends WebVRController {
  52750. /**
  52751. * Base Url for the controller model.
  52752. */
  52753. static readonly MODEL_BASE_URL: string;
  52754. /**
  52755. * File name for the controller model.
  52756. */
  52757. static readonly MODEL_FILENAME: string;
  52758. /**
  52759. * Creates a new GenericController from a gamepad
  52760. * @param vrGamepad the gamepad that the controller should be created from
  52761. */
  52762. constructor(vrGamepad: any);
  52763. /**
  52764. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52765. * @param scene scene in which to add meshes
  52766. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52767. */
  52768. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52769. /**
  52770. * Called once for each button that changed state since the last frame
  52771. * @param buttonIdx Which button index changed
  52772. * @param state New state of the button
  52773. * @param changes Which properties on the state changed since last frame
  52774. */
  52775. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52776. }
  52777. }
  52778. declare module BABYLON {
  52779. /**
  52780. * Oculus Touch Controller
  52781. */
  52782. export class OculusTouchController extends WebVRController {
  52783. /**
  52784. * Base Url for the controller model.
  52785. */
  52786. static MODEL_BASE_URL: string;
  52787. /**
  52788. * File name for the left controller model.
  52789. */
  52790. static MODEL_LEFT_FILENAME: string;
  52791. /**
  52792. * File name for the right controller model.
  52793. */
  52794. static MODEL_RIGHT_FILENAME: string;
  52795. /**
  52796. * Base Url for the Quest controller model.
  52797. */
  52798. static QUEST_MODEL_BASE_URL: string;
  52799. /**
  52800. * @hidden
  52801. * If the controllers are running on a device that needs the updated Quest controller models
  52802. */
  52803. static _IsQuest: boolean;
  52804. /**
  52805. * Fired when the secondary trigger on this controller is modified
  52806. */
  52807. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52808. /**
  52809. * Fired when the thumb rest on this controller is modified
  52810. */
  52811. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52812. /**
  52813. * Creates a new OculusTouchController from a gamepad
  52814. * @param vrGamepad the gamepad that the controller should be created from
  52815. */
  52816. constructor(vrGamepad: any);
  52817. /**
  52818. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52819. * @param scene scene in which to add meshes
  52820. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52821. */
  52822. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52823. /**
  52824. * Fired when the A button on this controller is modified
  52825. */
  52826. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52827. /**
  52828. * Fired when the B button on this controller is modified
  52829. */
  52830. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52831. /**
  52832. * Fired when the X button on this controller is modified
  52833. */
  52834. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52835. /**
  52836. * Fired when the Y button on this controller is modified
  52837. */
  52838. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52839. /**
  52840. * Called once for each button that changed state since the last frame
  52841. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52842. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52843. * 2) secondary trigger (same)
  52844. * 3) A (right) X (left), touch, pressed = value
  52845. * 4) B / Y
  52846. * 5) thumb rest
  52847. * @param buttonIdx Which button index changed
  52848. * @param state New state of the button
  52849. * @param changes Which properties on the state changed since last frame
  52850. */
  52851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52852. }
  52853. }
  52854. declare module BABYLON {
  52855. /**
  52856. * Vive Controller
  52857. */
  52858. export class ViveController extends WebVRController {
  52859. /**
  52860. * Base Url for the controller model.
  52861. */
  52862. static MODEL_BASE_URL: string;
  52863. /**
  52864. * File name for the controller model.
  52865. */
  52866. static MODEL_FILENAME: string;
  52867. /**
  52868. * Creates a new ViveController from a gamepad
  52869. * @param vrGamepad the gamepad that the controller should be created from
  52870. */
  52871. constructor(vrGamepad: any);
  52872. /**
  52873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52874. * @param scene scene in which to add meshes
  52875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52876. */
  52877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52878. /**
  52879. * Fired when the left button on this controller is modified
  52880. */
  52881. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52882. /**
  52883. * Fired when the right button on this controller is modified
  52884. */
  52885. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52886. /**
  52887. * Fired when the menu button on this controller is modified
  52888. */
  52889. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52890. /**
  52891. * Called once for each button that changed state since the last frame
  52892. * Vive mapping:
  52893. * 0: touchpad
  52894. * 1: trigger
  52895. * 2: left AND right buttons
  52896. * 3: menu button
  52897. * @param buttonIdx Which button index changed
  52898. * @param state New state of the button
  52899. * @param changes Which properties on the state changed since last frame
  52900. */
  52901. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52902. }
  52903. }
  52904. declare module BABYLON {
  52905. /**
  52906. * Defines the WindowsMotionController object that the state of the windows motion controller
  52907. */
  52908. export class WindowsMotionController extends WebVRController {
  52909. /**
  52910. * The base url used to load the left and right controller models
  52911. */
  52912. static MODEL_BASE_URL: string;
  52913. /**
  52914. * The name of the left controller model file
  52915. */
  52916. static MODEL_LEFT_FILENAME: string;
  52917. /**
  52918. * The name of the right controller model file
  52919. */
  52920. static MODEL_RIGHT_FILENAME: string;
  52921. /**
  52922. * The controller name prefix for this controller type
  52923. */
  52924. static readonly GAMEPAD_ID_PREFIX: string;
  52925. /**
  52926. * The controller id pattern for this controller type
  52927. */
  52928. private static readonly GAMEPAD_ID_PATTERN;
  52929. private _loadedMeshInfo;
  52930. protected readonly _mapping: {
  52931. buttons: string[];
  52932. buttonMeshNames: {
  52933. trigger: string;
  52934. menu: string;
  52935. grip: string;
  52936. thumbstick: string;
  52937. trackpad: string;
  52938. };
  52939. buttonObservableNames: {
  52940. trigger: string;
  52941. menu: string;
  52942. grip: string;
  52943. thumbstick: string;
  52944. trackpad: string;
  52945. };
  52946. axisMeshNames: string[];
  52947. pointingPoseMeshName: string;
  52948. };
  52949. /**
  52950. * Fired when the trackpad on this controller is clicked
  52951. */
  52952. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52953. /**
  52954. * Fired when the trackpad on this controller is modified
  52955. */
  52956. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52957. /**
  52958. * The current x and y values of this controller's trackpad
  52959. */
  52960. trackpad: StickValues;
  52961. /**
  52962. * Creates a new WindowsMotionController from a gamepad
  52963. * @param vrGamepad the gamepad that the controller should be created from
  52964. */
  52965. constructor(vrGamepad: any);
  52966. /**
  52967. * Fired when the trigger on this controller is modified
  52968. */
  52969. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52970. /**
  52971. * Fired when the menu button on this controller is modified
  52972. */
  52973. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52974. /**
  52975. * Fired when the grip button on this controller is modified
  52976. */
  52977. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52978. /**
  52979. * Fired when the thumbstick button on this controller is modified
  52980. */
  52981. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52982. /**
  52983. * Fired when the touchpad button on this controller is modified
  52984. */
  52985. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52986. /**
  52987. * Fired when the touchpad values on this controller are modified
  52988. */
  52989. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52990. protected _updateTrackpad(): void;
  52991. /**
  52992. * Called once per frame by the engine.
  52993. */
  52994. update(): void;
  52995. /**
  52996. * Called once for each button that changed state since the last frame
  52997. * @param buttonIdx Which button index changed
  52998. * @param state New state of the button
  52999. * @param changes Which properties on the state changed since last frame
  53000. */
  53001. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53002. /**
  53003. * Moves the buttons on the controller mesh based on their current state
  53004. * @param buttonName the name of the button to move
  53005. * @param buttonValue the value of the button which determines the buttons new position
  53006. */
  53007. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53008. /**
  53009. * Moves the axis on the controller mesh based on its current state
  53010. * @param axis the index of the axis
  53011. * @param axisValue the value of the axis which determines the meshes new position
  53012. * @hidden
  53013. */
  53014. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53015. /**
  53016. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53017. * @param scene scene in which to add meshes
  53018. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53019. */
  53020. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53021. /**
  53022. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53023. * can be transformed by button presses and axes values, based on this._mapping.
  53024. *
  53025. * @param scene scene in which the meshes exist
  53026. * @param meshes list of meshes that make up the controller model to process
  53027. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53028. */
  53029. private processModel;
  53030. private createMeshInfo;
  53031. /**
  53032. * Gets the ray of the controller in the direction the controller is pointing
  53033. * @param length the length the resulting ray should be
  53034. * @returns a ray in the direction the controller is pointing
  53035. */
  53036. getForwardRay(length?: number): Ray;
  53037. /**
  53038. * Disposes of the controller
  53039. */
  53040. dispose(): void;
  53041. }
  53042. /**
  53043. * This class represents a new windows motion controller in XR.
  53044. */
  53045. export class XRWindowsMotionController extends WindowsMotionController {
  53046. /**
  53047. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53048. */
  53049. protected readonly _mapping: {
  53050. buttons: string[];
  53051. buttonMeshNames: {
  53052. trigger: string;
  53053. menu: string;
  53054. grip: string;
  53055. thumbstick: string;
  53056. trackpad: string;
  53057. };
  53058. buttonObservableNames: {
  53059. trigger: string;
  53060. menu: string;
  53061. grip: string;
  53062. thumbstick: string;
  53063. trackpad: string;
  53064. };
  53065. axisMeshNames: string[];
  53066. pointingPoseMeshName: string;
  53067. };
  53068. /**
  53069. * Construct a new XR-Based windows motion controller
  53070. *
  53071. * @param gamepadInfo the gamepad object from the browser
  53072. */
  53073. constructor(gamepadInfo: any);
  53074. /**
  53075. * holds the thumbstick values (X,Y)
  53076. */
  53077. thumbstickValues: StickValues;
  53078. /**
  53079. * Fired when the thumbstick on this controller is clicked
  53080. */
  53081. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53082. /**
  53083. * Fired when the thumbstick on this controller is modified
  53084. */
  53085. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53086. /**
  53087. * Fired when the touchpad button on this controller is modified
  53088. */
  53089. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53090. /**
  53091. * Fired when the touchpad values on this controller are modified
  53092. */
  53093. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53094. /**
  53095. * Fired when the thumbstick button on this controller is modified
  53096. * here to prevent breaking changes
  53097. */
  53098. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53099. /**
  53100. * updating the thumbstick(!) and not the trackpad.
  53101. * This is named this way due to the difference between WebVR and XR and to avoid
  53102. * changing the parent class.
  53103. */
  53104. protected _updateTrackpad(): void;
  53105. /**
  53106. * Disposes the class with joy
  53107. */
  53108. dispose(): void;
  53109. }
  53110. }
  53111. declare module BABYLON {
  53112. /**
  53113. * Class containing static functions to help procedurally build meshes
  53114. */
  53115. export class PolyhedronBuilder {
  53116. /**
  53117. * Creates a polyhedron mesh
  53118. * * 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
  53119. * * The parameter `size` (positive float, default 1) sets the polygon size
  53120. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53121. * * 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`
  53122. * * 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
  53123. * * 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)`)
  53124. * * 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
  53125. * * 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
  53126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53127. * * 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
  53128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53129. * @param name defines the name of the mesh
  53130. * @param options defines the options used to create the mesh
  53131. * @param scene defines the hosting scene
  53132. * @returns the polyhedron mesh
  53133. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53134. */
  53135. static CreatePolyhedron(name: string, options: {
  53136. type?: number;
  53137. size?: number;
  53138. sizeX?: number;
  53139. sizeY?: number;
  53140. sizeZ?: number;
  53141. custom?: any;
  53142. faceUV?: Vector4[];
  53143. faceColors?: Color4[];
  53144. flat?: boolean;
  53145. updatable?: boolean;
  53146. sideOrientation?: number;
  53147. frontUVs?: Vector4;
  53148. backUVs?: Vector4;
  53149. }, scene?: Nullable<Scene>): Mesh;
  53150. }
  53151. }
  53152. declare module BABYLON {
  53153. /**
  53154. * Gizmo that enables scaling a mesh along 3 axis
  53155. */
  53156. export class ScaleGizmo extends Gizmo {
  53157. /**
  53158. * Internal gizmo used for interactions on the x axis
  53159. */
  53160. xGizmo: AxisScaleGizmo;
  53161. /**
  53162. * Internal gizmo used for interactions on the y axis
  53163. */
  53164. yGizmo: AxisScaleGizmo;
  53165. /**
  53166. * Internal gizmo used for interactions on the z axis
  53167. */
  53168. zGizmo: AxisScaleGizmo;
  53169. /**
  53170. * Internal gizmo used to scale all axis equally
  53171. */
  53172. uniformScaleGizmo: AxisScaleGizmo;
  53173. private _meshAttached;
  53174. private _nodeAttached;
  53175. private _updateGizmoRotationToMatchAttachedMesh;
  53176. private _snapDistance;
  53177. private _scaleRatio;
  53178. private _uniformScalingMesh;
  53179. private _octahedron;
  53180. private _sensitivity;
  53181. /** Fires an event when any of it's sub gizmos are dragged */
  53182. onDragStartObservable: Observable<unknown>;
  53183. /** Fires an event when any of it's sub gizmos are released from dragging */
  53184. onDragEndObservable: Observable<unknown>;
  53185. get attachedMesh(): Nullable<AbstractMesh>;
  53186. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53187. get attachedNode(): Nullable<Node>;
  53188. set attachedNode(node: Nullable<Node>);
  53189. /**
  53190. * Creates a ScaleGizmo
  53191. * @param gizmoLayer The utility layer the gizmo will be added to
  53192. * @param thickness display gizmo axis thickness
  53193. */
  53194. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53195. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53196. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53197. /**
  53198. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53199. */
  53200. set snapDistance(value: number);
  53201. get snapDistance(): number;
  53202. /**
  53203. * Ratio for the scale of the gizmo (Default: 1)
  53204. */
  53205. set scaleRatio(value: number);
  53206. get scaleRatio(): number;
  53207. /**
  53208. * Sensitivity factor for dragging (Default: 1)
  53209. */
  53210. set sensitivity(value: number);
  53211. get sensitivity(): number;
  53212. /**
  53213. * Disposes of the gizmo
  53214. */
  53215. dispose(): void;
  53216. }
  53217. }
  53218. declare module BABYLON {
  53219. /**
  53220. * Single axis scale gizmo
  53221. */
  53222. export class AxisScaleGizmo extends Gizmo {
  53223. /**
  53224. * Drag behavior responsible for the gizmos dragging interactions
  53225. */
  53226. dragBehavior: PointerDragBehavior;
  53227. private _pointerObserver;
  53228. /**
  53229. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53230. */
  53231. snapDistance: number;
  53232. /**
  53233. * Event that fires each time the gizmo snaps to a new location.
  53234. * * snapDistance is the the change in distance
  53235. */
  53236. onSnapObservable: Observable<{
  53237. snapDistance: number;
  53238. }>;
  53239. /**
  53240. * If the scaling operation should be done on all axis (default: false)
  53241. */
  53242. uniformScaling: boolean;
  53243. /**
  53244. * Custom sensitivity value for the drag strength
  53245. */
  53246. sensitivity: number;
  53247. private _isEnabled;
  53248. private _parent;
  53249. private _arrow;
  53250. private _coloredMaterial;
  53251. private _hoverMaterial;
  53252. /**
  53253. * Creates an AxisScaleGizmo
  53254. * @param gizmoLayer The utility layer the gizmo will be added to
  53255. * @param dragAxis The axis which the gizmo will be able to scale on
  53256. * @param color The color of the gizmo
  53257. * @param thickness display gizmo axis thickness
  53258. */
  53259. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53260. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53261. /**
  53262. * If the gizmo is enabled
  53263. */
  53264. set isEnabled(value: boolean);
  53265. get isEnabled(): boolean;
  53266. /**
  53267. * Disposes of the gizmo
  53268. */
  53269. dispose(): void;
  53270. /**
  53271. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53272. * @param mesh The mesh to replace the default mesh of the gizmo
  53273. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53274. */
  53275. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53276. }
  53277. }
  53278. declare module BABYLON {
  53279. /**
  53280. * Bounding box gizmo
  53281. */
  53282. export class BoundingBoxGizmo extends Gizmo {
  53283. private _lineBoundingBox;
  53284. private _rotateSpheresParent;
  53285. private _scaleBoxesParent;
  53286. private _boundingDimensions;
  53287. private _renderObserver;
  53288. private _pointerObserver;
  53289. private _scaleDragSpeed;
  53290. private _tmpQuaternion;
  53291. private _tmpVector;
  53292. private _tmpRotationMatrix;
  53293. /**
  53294. * 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)
  53295. */
  53296. ignoreChildren: boolean;
  53297. /**
  53298. * 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)
  53299. */
  53300. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53301. /**
  53302. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53303. */
  53304. rotationSphereSize: number;
  53305. /**
  53306. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53307. */
  53308. scaleBoxSize: number;
  53309. /**
  53310. * 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)
  53311. */
  53312. fixedDragMeshScreenSize: boolean;
  53313. /**
  53314. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53315. */
  53316. fixedDragMeshScreenSizeDistanceFactor: number;
  53317. /**
  53318. * Fired when a rotation sphere or scale box is dragged
  53319. */
  53320. onDragStartObservable: Observable<{}>;
  53321. /**
  53322. * Fired when a scale box is dragged
  53323. */
  53324. onScaleBoxDragObservable: Observable<{}>;
  53325. /**
  53326. * Fired when a scale box drag is ended
  53327. */
  53328. onScaleBoxDragEndObservable: Observable<{}>;
  53329. /**
  53330. * Fired when a rotation sphere is dragged
  53331. */
  53332. onRotationSphereDragObservable: Observable<{}>;
  53333. /**
  53334. * Fired when a rotation sphere drag is ended
  53335. */
  53336. onRotationSphereDragEndObservable: Observable<{}>;
  53337. /**
  53338. * 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)
  53339. */
  53340. scalePivot: Nullable<Vector3>;
  53341. /**
  53342. * Mesh used as a pivot to rotate the attached node
  53343. */
  53344. private _anchorMesh;
  53345. private _existingMeshScale;
  53346. private _dragMesh;
  53347. private pointerDragBehavior;
  53348. private coloredMaterial;
  53349. private hoverColoredMaterial;
  53350. /**
  53351. * Sets the color of the bounding box gizmo
  53352. * @param color the color to set
  53353. */
  53354. setColor(color: Color3): void;
  53355. /**
  53356. * Creates an BoundingBoxGizmo
  53357. * @param gizmoLayer The utility layer the gizmo will be added to
  53358. * @param color The color of the gizmo
  53359. */
  53360. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53361. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53362. private _selectNode;
  53363. /**
  53364. * Updates the bounding box information for the Gizmo
  53365. */
  53366. updateBoundingBox(): void;
  53367. private _updateRotationSpheres;
  53368. private _updateScaleBoxes;
  53369. /**
  53370. * Enables rotation on the specified axis and disables rotation on the others
  53371. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53372. */
  53373. setEnabledRotationAxis(axis: string): void;
  53374. /**
  53375. * Enables/disables scaling
  53376. * @param enable if scaling should be enabled
  53377. * @param homogeneousScaling defines if scaling should only be homogeneous
  53378. */
  53379. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53380. private _updateDummy;
  53381. /**
  53382. * Enables a pointer drag behavior on the bounding box of the gizmo
  53383. */
  53384. enableDragBehavior(): void;
  53385. /**
  53386. * Disposes of the gizmo
  53387. */
  53388. dispose(): void;
  53389. /**
  53390. * 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)
  53391. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53392. * @returns the bounding box mesh with the passed in mesh as a child
  53393. */
  53394. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53395. /**
  53396. * CustomMeshes are not supported by this gizmo
  53397. * @param mesh The mesh to replace the default mesh of the gizmo
  53398. */
  53399. setCustomMesh(mesh: Mesh): void;
  53400. }
  53401. }
  53402. declare module BABYLON {
  53403. /**
  53404. * Single plane rotation gizmo
  53405. */
  53406. export class PlaneRotationGizmo extends Gizmo {
  53407. /**
  53408. * Drag behavior responsible for the gizmos dragging interactions
  53409. */
  53410. dragBehavior: PointerDragBehavior;
  53411. private _pointerObserver;
  53412. /**
  53413. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53414. */
  53415. snapDistance: number;
  53416. /**
  53417. * Event that fires each time the gizmo snaps to a new location.
  53418. * * snapDistance is the the change in distance
  53419. */
  53420. onSnapObservable: Observable<{
  53421. snapDistance: number;
  53422. }>;
  53423. private _isEnabled;
  53424. private _parent;
  53425. /**
  53426. * Creates a PlaneRotationGizmo
  53427. * @param gizmoLayer The utility layer the gizmo will be added to
  53428. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53429. * @param color The color of the gizmo
  53430. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53431. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53432. * @param thickness display gizmo axis thickness
  53433. */
  53434. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53435. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53436. /**
  53437. * If the gizmo is enabled
  53438. */
  53439. set isEnabled(value: boolean);
  53440. get isEnabled(): boolean;
  53441. /**
  53442. * Disposes of the gizmo
  53443. */
  53444. dispose(): void;
  53445. }
  53446. }
  53447. declare module BABYLON {
  53448. /**
  53449. * Gizmo that enables rotating a mesh along 3 axis
  53450. */
  53451. export class RotationGizmo extends Gizmo {
  53452. /**
  53453. * Internal gizmo used for interactions on the x axis
  53454. */
  53455. xGizmo: PlaneRotationGizmo;
  53456. /**
  53457. * Internal gizmo used for interactions on the y axis
  53458. */
  53459. yGizmo: PlaneRotationGizmo;
  53460. /**
  53461. * Internal gizmo used for interactions on the z axis
  53462. */
  53463. zGizmo: PlaneRotationGizmo;
  53464. /** Fires an event when any of it's sub gizmos are dragged */
  53465. onDragStartObservable: Observable<unknown>;
  53466. /** Fires an event when any of it's sub gizmos are released from dragging */
  53467. onDragEndObservable: Observable<unknown>;
  53468. private _meshAttached;
  53469. private _nodeAttached;
  53470. get attachedMesh(): Nullable<AbstractMesh>;
  53471. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53472. get attachedNode(): Nullable<Node>;
  53473. set attachedNode(node: Nullable<Node>);
  53474. /**
  53475. * Creates a RotationGizmo
  53476. * @param gizmoLayer The utility layer the gizmo will be added to
  53477. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53478. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53479. * @param thickness display gizmo axis thickness
  53480. */
  53481. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53482. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53483. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53484. /**
  53485. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53486. */
  53487. set snapDistance(value: number);
  53488. get snapDistance(): number;
  53489. /**
  53490. * Ratio for the scale of the gizmo (Default: 1)
  53491. */
  53492. set scaleRatio(value: number);
  53493. get scaleRatio(): number;
  53494. /**
  53495. * Disposes of the gizmo
  53496. */
  53497. dispose(): void;
  53498. /**
  53499. * CustomMeshes are not supported by this gizmo
  53500. * @param mesh The mesh to replace the default mesh of the gizmo
  53501. */
  53502. setCustomMesh(mesh: Mesh): void;
  53503. }
  53504. }
  53505. declare module BABYLON {
  53506. /**
  53507. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53508. */
  53509. export class GizmoManager implements IDisposable {
  53510. private scene;
  53511. /**
  53512. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53513. */
  53514. gizmos: {
  53515. positionGizmo: Nullable<PositionGizmo>;
  53516. rotationGizmo: Nullable<RotationGizmo>;
  53517. scaleGizmo: Nullable<ScaleGizmo>;
  53518. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53519. };
  53520. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53521. clearGizmoOnEmptyPointerEvent: boolean;
  53522. /** Fires an event when the manager is attached to a mesh */
  53523. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53524. private _gizmosEnabled;
  53525. private _pointerObserver;
  53526. private _attachedMesh;
  53527. private _boundingBoxColor;
  53528. private _defaultUtilityLayer;
  53529. private _defaultKeepDepthUtilityLayer;
  53530. private _thickness;
  53531. /**
  53532. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53533. */
  53534. boundingBoxDragBehavior: SixDofDragBehavior;
  53535. /**
  53536. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53537. */
  53538. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53539. /**
  53540. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53541. */
  53542. usePointerToAttachGizmos: boolean;
  53543. /**
  53544. * Utility layer that the bounding box gizmo belongs to
  53545. */
  53546. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53547. /**
  53548. * Utility layer that all gizmos besides bounding box belong to
  53549. */
  53550. get utilityLayer(): UtilityLayerRenderer;
  53551. /**
  53552. * Instatiates a gizmo manager
  53553. * @param scene the scene to overlay the gizmos on top of
  53554. * @param thickness display gizmo axis thickness
  53555. */
  53556. constructor(scene: Scene, thickness?: number);
  53557. /**
  53558. * Attaches a set of gizmos to the specified mesh
  53559. * @param mesh The mesh the gizmo's should be attached to
  53560. */
  53561. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53562. /**
  53563. * If the position gizmo is enabled
  53564. */
  53565. set positionGizmoEnabled(value: boolean);
  53566. get positionGizmoEnabled(): boolean;
  53567. /**
  53568. * If the rotation gizmo is enabled
  53569. */
  53570. set rotationGizmoEnabled(value: boolean);
  53571. get rotationGizmoEnabled(): boolean;
  53572. /**
  53573. * If the scale gizmo is enabled
  53574. */
  53575. set scaleGizmoEnabled(value: boolean);
  53576. get scaleGizmoEnabled(): boolean;
  53577. /**
  53578. * If the boundingBox gizmo is enabled
  53579. */
  53580. set boundingBoxGizmoEnabled(value: boolean);
  53581. get boundingBoxGizmoEnabled(): boolean;
  53582. /**
  53583. * Disposes of the gizmo manager
  53584. */
  53585. dispose(): void;
  53586. }
  53587. }
  53588. declare module BABYLON {
  53589. /**
  53590. * A directional light is defined by a direction (what a surprise!).
  53591. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53592. * 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.
  53593. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53594. */
  53595. export class DirectionalLight extends ShadowLight {
  53596. private _shadowFrustumSize;
  53597. /**
  53598. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53599. */
  53600. get shadowFrustumSize(): number;
  53601. /**
  53602. * Specifies a fix frustum size for the shadow generation.
  53603. */
  53604. set shadowFrustumSize(value: number);
  53605. private _shadowOrthoScale;
  53606. /**
  53607. * Gets the shadow projection scale against the optimal computed one.
  53608. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53609. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53610. */
  53611. get shadowOrthoScale(): number;
  53612. /**
  53613. * Sets the shadow projection scale against the optimal computed one.
  53614. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53615. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53616. */
  53617. set shadowOrthoScale(value: number);
  53618. /**
  53619. * Automatically compute the projection matrix to best fit (including all the casters)
  53620. * on each frame.
  53621. */
  53622. autoUpdateExtends: boolean;
  53623. /**
  53624. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53625. * on each frame. autoUpdateExtends must be set to true for this to work
  53626. */
  53627. autoCalcShadowZBounds: boolean;
  53628. private _orthoLeft;
  53629. private _orthoRight;
  53630. private _orthoTop;
  53631. private _orthoBottom;
  53632. /**
  53633. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53634. * The directional light is emitted from everywhere in the given direction.
  53635. * It can cast shadows.
  53636. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53637. * @param name The friendly name of the light
  53638. * @param direction The direction of the light
  53639. * @param scene The scene the light belongs to
  53640. */
  53641. constructor(name: string, direction: Vector3, scene: Scene);
  53642. /**
  53643. * Returns the string "DirectionalLight".
  53644. * @return The class name
  53645. */
  53646. getClassName(): string;
  53647. /**
  53648. * Returns the integer 1.
  53649. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53650. */
  53651. getTypeID(): number;
  53652. /**
  53653. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53654. * Returns the DirectionalLight Shadow projection matrix.
  53655. */
  53656. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53657. /**
  53658. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53659. * Returns the DirectionalLight Shadow projection matrix.
  53660. */
  53661. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53662. /**
  53663. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53664. * Returns the DirectionalLight Shadow projection matrix.
  53665. */
  53666. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53667. protected _buildUniformLayout(): void;
  53668. /**
  53669. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53670. * @param effect The effect to update
  53671. * @param lightIndex The index of the light in the effect to update
  53672. * @returns The directional light
  53673. */
  53674. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53675. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53676. /**
  53677. * Gets the minZ used for shadow according to both the scene and the light.
  53678. *
  53679. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53680. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53681. * @param activeCamera The camera we are returning the min for
  53682. * @returns the depth min z
  53683. */
  53684. getDepthMinZ(activeCamera: Camera): number;
  53685. /**
  53686. * Gets the maxZ used for shadow according to both the scene and the light.
  53687. *
  53688. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53689. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53690. * @param activeCamera The camera we are returning the max for
  53691. * @returns the depth max z
  53692. */
  53693. getDepthMaxZ(activeCamera: Camera): number;
  53694. /**
  53695. * Prepares the list of defines specific to the light type.
  53696. * @param defines the list of defines
  53697. * @param lightIndex defines the index of the light for the effect
  53698. */
  53699. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53700. }
  53701. }
  53702. declare module BABYLON {
  53703. /**
  53704. * Class containing static functions to help procedurally build meshes
  53705. */
  53706. export class HemisphereBuilder {
  53707. /**
  53708. * Creates a hemisphere mesh
  53709. * @param name defines the name of the mesh
  53710. * @param options defines the options used to create the mesh
  53711. * @param scene defines the hosting scene
  53712. * @returns the hemisphere mesh
  53713. */
  53714. static CreateHemisphere(name: string, options: {
  53715. segments?: number;
  53716. diameter?: number;
  53717. sideOrientation?: number;
  53718. }, scene: any): Mesh;
  53719. }
  53720. }
  53721. declare module BABYLON {
  53722. /**
  53723. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53724. * These values define a cone of light starting from the position, emitting toward the direction.
  53725. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53726. * and the exponent defines the speed of the decay of the light with distance (reach).
  53727. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53728. */
  53729. export class SpotLight extends ShadowLight {
  53730. private _angle;
  53731. private _innerAngle;
  53732. private _cosHalfAngle;
  53733. private _lightAngleScale;
  53734. private _lightAngleOffset;
  53735. /**
  53736. * Gets the cone angle of the spot light in Radians.
  53737. */
  53738. get angle(): number;
  53739. /**
  53740. * Sets the cone angle of the spot light in Radians.
  53741. */
  53742. set angle(value: number);
  53743. /**
  53744. * Only used in gltf falloff mode, this defines the angle where
  53745. * the directional falloff will start before cutting at angle which could be seen
  53746. * as outer angle.
  53747. */
  53748. get innerAngle(): number;
  53749. /**
  53750. * Only used in gltf falloff mode, this defines the angle where
  53751. * the directional falloff will start before cutting at angle which could be seen
  53752. * as outer angle.
  53753. */
  53754. set innerAngle(value: number);
  53755. private _shadowAngleScale;
  53756. /**
  53757. * Allows scaling the angle of the light for shadow generation only.
  53758. */
  53759. get shadowAngleScale(): number;
  53760. /**
  53761. * Allows scaling the angle of the light for shadow generation only.
  53762. */
  53763. set shadowAngleScale(value: number);
  53764. /**
  53765. * The light decay speed with the distance from the emission spot.
  53766. */
  53767. exponent: number;
  53768. private _projectionTextureMatrix;
  53769. /**
  53770. * Allows reading the projecton texture
  53771. */
  53772. get projectionTextureMatrix(): Matrix;
  53773. protected _projectionTextureLightNear: number;
  53774. /**
  53775. * Gets the near clip of the Spotlight for texture projection.
  53776. */
  53777. get projectionTextureLightNear(): number;
  53778. /**
  53779. * Sets the near clip of the Spotlight for texture projection.
  53780. */
  53781. set projectionTextureLightNear(value: number);
  53782. protected _projectionTextureLightFar: number;
  53783. /**
  53784. * Gets the far clip of the Spotlight for texture projection.
  53785. */
  53786. get projectionTextureLightFar(): number;
  53787. /**
  53788. * Sets the far clip of the Spotlight for texture projection.
  53789. */
  53790. set projectionTextureLightFar(value: number);
  53791. protected _projectionTextureUpDirection: Vector3;
  53792. /**
  53793. * Gets the Up vector of the Spotlight for texture projection.
  53794. */
  53795. get projectionTextureUpDirection(): Vector3;
  53796. /**
  53797. * Sets the Up vector of the Spotlight for texture projection.
  53798. */
  53799. set projectionTextureUpDirection(value: Vector3);
  53800. private _projectionTexture;
  53801. /**
  53802. * Gets the projection texture of the light.
  53803. */
  53804. get projectionTexture(): Nullable<BaseTexture>;
  53805. /**
  53806. * Sets the projection texture of the light.
  53807. */
  53808. set projectionTexture(value: Nullable<BaseTexture>);
  53809. private _projectionTextureViewLightDirty;
  53810. private _projectionTextureProjectionLightDirty;
  53811. private _projectionTextureDirty;
  53812. private _projectionTextureViewTargetVector;
  53813. private _projectionTextureViewLightMatrix;
  53814. private _projectionTextureProjectionLightMatrix;
  53815. private _projectionTextureScalingMatrix;
  53816. /**
  53817. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53818. * It can cast shadows.
  53819. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53820. * @param name The light friendly name
  53821. * @param position The position of the spot light in the scene
  53822. * @param direction The direction of the light in the scene
  53823. * @param angle The cone angle of the light in Radians
  53824. * @param exponent The light decay speed with the distance from the emission spot
  53825. * @param scene The scene the lights belongs to
  53826. */
  53827. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53828. /**
  53829. * Returns the string "SpotLight".
  53830. * @returns the class name
  53831. */
  53832. getClassName(): string;
  53833. /**
  53834. * Returns the integer 2.
  53835. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53836. */
  53837. getTypeID(): number;
  53838. /**
  53839. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53840. */
  53841. protected _setDirection(value: Vector3): void;
  53842. /**
  53843. * Overrides the position setter to recompute the projection texture view light Matrix.
  53844. */
  53845. protected _setPosition(value: Vector3): void;
  53846. /**
  53847. * 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.
  53848. * Returns the SpotLight.
  53849. */
  53850. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53851. protected _computeProjectionTextureViewLightMatrix(): void;
  53852. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53853. /**
  53854. * Main function for light texture projection matrix computing.
  53855. */
  53856. protected _computeProjectionTextureMatrix(): void;
  53857. protected _buildUniformLayout(): void;
  53858. private _computeAngleValues;
  53859. /**
  53860. * Sets the passed Effect "effect" with the Light textures.
  53861. * @param effect The effect to update
  53862. * @param lightIndex The index of the light in the effect to update
  53863. * @returns The light
  53864. */
  53865. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53866. /**
  53867. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53868. * @param effect The effect to update
  53869. * @param lightIndex The index of the light in the effect to update
  53870. * @returns The spot light
  53871. */
  53872. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53873. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53874. /**
  53875. * Disposes the light and the associated resources.
  53876. */
  53877. dispose(): void;
  53878. /**
  53879. * Prepares the list of defines specific to the light type.
  53880. * @param defines the list of defines
  53881. * @param lightIndex defines the index of the light for the effect
  53882. */
  53883. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53884. }
  53885. }
  53886. declare module BABYLON {
  53887. /**
  53888. * Gizmo that enables viewing a light
  53889. */
  53890. export class LightGizmo extends Gizmo {
  53891. private _lightMesh;
  53892. private _material;
  53893. private _cachedPosition;
  53894. private _cachedForward;
  53895. private _attachedMeshParent;
  53896. /**
  53897. * Creates a LightGizmo
  53898. * @param gizmoLayer The utility layer the gizmo will be added to
  53899. */
  53900. constructor(gizmoLayer?: UtilityLayerRenderer);
  53901. private _light;
  53902. /**
  53903. * The light that the gizmo is attached to
  53904. */
  53905. set light(light: Nullable<Light>);
  53906. get light(): Nullable<Light>;
  53907. /**
  53908. * Gets the material used to render the light gizmo
  53909. */
  53910. get material(): StandardMaterial;
  53911. /**
  53912. * @hidden
  53913. * Updates the gizmo to match the attached mesh's position/rotation
  53914. */
  53915. protected _update(): void;
  53916. private static _Scale;
  53917. /**
  53918. * Creates the lines for a light mesh
  53919. */
  53920. private static _CreateLightLines;
  53921. /**
  53922. * Disposes of the light gizmo
  53923. */
  53924. dispose(): void;
  53925. private static _CreateHemisphericLightMesh;
  53926. private static _CreatePointLightMesh;
  53927. private static _CreateSpotLightMesh;
  53928. private static _CreateDirectionalLightMesh;
  53929. }
  53930. }
  53931. declare module BABYLON {
  53932. /** @hidden */
  53933. export var backgroundFragmentDeclaration: {
  53934. name: string;
  53935. shader: string;
  53936. };
  53937. }
  53938. declare module BABYLON {
  53939. /** @hidden */
  53940. export var backgroundUboDeclaration: {
  53941. name: string;
  53942. shader: string;
  53943. };
  53944. }
  53945. declare module BABYLON {
  53946. /** @hidden */
  53947. export var backgroundPixelShader: {
  53948. name: string;
  53949. shader: string;
  53950. };
  53951. }
  53952. declare module BABYLON {
  53953. /** @hidden */
  53954. export var backgroundVertexDeclaration: {
  53955. name: string;
  53956. shader: string;
  53957. };
  53958. }
  53959. declare module BABYLON {
  53960. /** @hidden */
  53961. export var backgroundVertexShader: {
  53962. name: string;
  53963. shader: string;
  53964. };
  53965. }
  53966. declare module BABYLON {
  53967. /**
  53968. * Background material used to create an efficient environement around your scene.
  53969. */
  53970. export class BackgroundMaterial extends PushMaterial {
  53971. /**
  53972. * Standard reflectance value at parallel view angle.
  53973. */
  53974. static StandardReflectance0: number;
  53975. /**
  53976. * Standard reflectance value at grazing angle.
  53977. */
  53978. static StandardReflectance90: number;
  53979. protected _primaryColor: Color3;
  53980. /**
  53981. * Key light Color (multiply against the environement texture)
  53982. */
  53983. primaryColor: Color3;
  53984. protected __perceptualColor: Nullable<Color3>;
  53985. /**
  53986. * Experimental Internal Use Only.
  53987. *
  53988. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53989. * This acts as a helper to set the primary color to a more "human friendly" value.
  53990. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53991. * output color as close as possible from the chosen value.
  53992. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53993. * part of lighting setup.)
  53994. */
  53995. get _perceptualColor(): Nullable<Color3>;
  53996. set _perceptualColor(value: Nullable<Color3>);
  53997. protected _primaryColorShadowLevel: float;
  53998. /**
  53999. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54000. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54001. */
  54002. get primaryColorShadowLevel(): float;
  54003. set primaryColorShadowLevel(value: float);
  54004. protected _primaryColorHighlightLevel: float;
  54005. /**
  54006. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54007. * The primary color is used at the level chosen to define what the white area would look.
  54008. */
  54009. get primaryColorHighlightLevel(): float;
  54010. set primaryColorHighlightLevel(value: float);
  54011. protected _reflectionTexture: Nullable<BaseTexture>;
  54012. /**
  54013. * Reflection Texture used in the material.
  54014. * Should be author in a specific way for the best result (refer to the documentation).
  54015. */
  54016. reflectionTexture: Nullable<BaseTexture>;
  54017. protected _reflectionBlur: float;
  54018. /**
  54019. * Reflection Texture level of blur.
  54020. *
  54021. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54022. * texture twice.
  54023. */
  54024. reflectionBlur: float;
  54025. protected _diffuseTexture: Nullable<BaseTexture>;
  54026. /**
  54027. * Diffuse Texture used in the material.
  54028. * Should be author in a specific way for the best result (refer to the documentation).
  54029. */
  54030. diffuseTexture: Nullable<BaseTexture>;
  54031. protected _shadowLights: Nullable<IShadowLight[]>;
  54032. /**
  54033. * Specify the list of lights casting shadow on the material.
  54034. * All scene shadow lights will be included if null.
  54035. */
  54036. shadowLights: Nullable<IShadowLight[]>;
  54037. protected _shadowLevel: float;
  54038. /**
  54039. * Helps adjusting the shadow to a softer level if required.
  54040. * 0 means black shadows and 1 means no shadows.
  54041. */
  54042. shadowLevel: float;
  54043. protected _sceneCenter: Vector3;
  54044. /**
  54045. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54046. * It is usually zero but might be interesting to modify according to your setup.
  54047. */
  54048. sceneCenter: Vector3;
  54049. protected _opacityFresnel: boolean;
  54050. /**
  54051. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54052. * This helps ensuring a nice transition when the camera goes under the ground.
  54053. */
  54054. opacityFresnel: boolean;
  54055. protected _reflectionFresnel: boolean;
  54056. /**
  54057. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54058. * This helps adding a mirror texture on the ground.
  54059. */
  54060. reflectionFresnel: boolean;
  54061. protected _reflectionFalloffDistance: number;
  54062. /**
  54063. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54064. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54065. */
  54066. reflectionFalloffDistance: number;
  54067. protected _reflectionAmount: number;
  54068. /**
  54069. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54070. */
  54071. reflectionAmount: number;
  54072. protected _reflectionReflectance0: number;
  54073. /**
  54074. * This specifies the weight of the reflection at grazing angle.
  54075. */
  54076. reflectionReflectance0: number;
  54077. protected _reflectionReflectance90: number;
  54078. /**
  54079. * This specifies the weight of the reflection at a perpendicular point of view.
  54080. */
  54081. reflectionReflectance90: number;
  54082. /**
  54083. * Sets the reflection reflectance fresnel values according to the default standard
  54084. * empirically know to work well :-)
  54085. */
  54086. set reflectionStandardFresnelWeight(value: number);
  54087. protected _useRGBColor: boolean;
  54088. /**
  54089. * Helps to directly use the maps channels instead of their level.
  54090. */
  54091. useRGBColor: boolean;
  54092. protected _enableNoise: boolean;
  54093. /**
  54094. * This helps reducing the banding effect that could occur on the background.
  54095. */
  54096. enableNoise: boolean;
  54097. /**
  54098. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54099. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54100. * Recommended to be keep at 1.0 except for special cases.
  54101. */
  54102. get fovMultiplier(): number;
  54103. set fovMultiplier(value: number);
  54104. private _fovMultiplier;
  54105. /**
  54106. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54107. */
  54108. useEquirectangularFOV: boolean;
  54109. private _maxSimultaneousLights;
  54110. /**
  54111. * Number of Simultaneous lights allowed on the material.
  54112. */
  54113. maxSimultaneousLights: int;
  54114. private _shadowOnly;
  54115. /**
  54116. * Make the material only render shadows
  54117. */
  54118. shadowOnly: boolean;
  54119. /**
  54120. * Default configuration related to image processing available in the Background Material.
  54121. */
  54122. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54123. /**
  54124. * Keep track of the image processing observer to allow dispose and replace.
  54125. */
  54126. private _imageProcessingObserver;
  54127. /**
  54128. * Attaches a new image processing configuration to the PBR Material.
  54129. * @param configuration (if null the scene configuration will be use)
  54130. */
  54131. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54132. /**
  54133. * Gets the image processing configuration used either in this material.
  54134. */
  54135. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54136. /**
  54137. * Sets the Default image processing configuration used either in the this material.
  54138. *
  54139. * If sets to null, the scene one is in use.
  54140. */
  54141. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54142. /**
  54143. * Gets wether the color curves effect is enabled.
  54144. */
  54145. get cameraColorCurvesEnabled(): boolean;
  54146. /**
  54147. * Sets wether the color curves effect is enabled.
  54148. */
  54149. set cameraColorCurvesEnabled(value: boolean);
  54150. /**
  54151. * Gets wether the color grading effect is enabled.
  54152. */
  54153. get cameraColorGradingEnabled(): boolean;
  54154. /**
  54155. * Gets wether the color grading effect is enabled.
  54156. */
  54157. set cameraColorGradingEnabled(value: boolean);
  54158. /**
  54159. * Gets wether tonemapping is enabled or not.
  54160. */
  54161. get cameraToneMappingEnabled(): boolean;
  54162. /**
  54163. * Sets wether tonemapping is enabled or not
  54164. */
  54165. set cameraToneMappingEnabled(value: boolean);
  54166. /**
  54167. * The camera exposure used on this material.
  54168. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54169. * This corresponds to a photographic exposure.
  54170. */
  54171. get cameraExposure(): float;
  54172. /**
  54173. * The camera exposure used on this material.
  54174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54175. * This corresponds to a photographic exposure.
  54176. */
  54177. set cameraExposure(value: float);
  54178. /**
  54179. * Gets The camera contrast used on this material.
  54180. */
  54181. get cameraContrast(): float;
  54182. /**
  54183. * Sets The camera contrast used on this material.
  54184. */
  54185. set cameraContrast(value: float);
  54186. /**
  54187. * Gets the Color Grading 2D Lookup Texture.
  54188. */
  54189. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54190. /**
  54191. * Sets the Color Grading 2D Lookup Texture.
  54192. */
  54193. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54194. /**
  54195. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54196. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54197. * 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;
  54198. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54199. */
  54200. get cameraColorCurves(): Nullable<ColorCurves>;
  54201. /**
  54202. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54203. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54204. * 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;
  54205. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54206. */
  54207. set cameraColorCurves(value: Nullable<ColorCurves>);
  54208. /**
  54209. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54210. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54211. */
  54212. switchToBGR: boolean;
  54213. private _renderTargets;
  54214. private _reflectionControls;
  54215. private _white;
  54216. private _primaryShadowColor;
  54217. private _primaryHighlightColor;
  54218. /**
  54219. * Instantiates a Background Material in the given scene
  54220. * @param name The friendly name of the material
  54221. * @param scene The scene to add the material to
  54222. */
  54223. constructor(name: string, scene: Scene);
  54224. /**
  54225. * Gets a boolean indicating that current material needs to register RTT
  54226. */
  54227. get hasRenderTargetTextures(): boolean;
  54228. /**
  54229. * The entire material has been created in order to prevent overdraw.
  54230. * @returns false
  54231. */
  54232. needAlphaTesting(): boolean;
  54233. /**
  54234. * The entire material has been created in order to prevent overdraw.
  54235. * @returns true if blending is enable
  54236. */
  54237. needAlphaBlending(): boolean;
  54238. /**
  54239. * Checks wether the material is ready to be rendered for a given mesh.
  54240. * @param mesh The mesh to render
  54241. * @param subMesh The submesh to check against
  54242. * @param useInstances Specify wether or not the material is used with instances
  54243. * @returns true if all the dependencies are ready (Textures, Effects...)
  54244. */
  54245. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54246. /**
  54247. * Compute the primary color according to the chosen perceptual color.
  54248. */
  54249. private _computePrimaryColorFromPerceptualColor;
  54250. /**
  54251. * Compute the highlights and shadow colors according to their chosen levels.
  54252. */
  54253. private _computePrimaryColors;
  54254. /**
  54255. * Build the uniform buffer used in the material.
  54256. */
  54257. buildUniformLayout(): void;
  54258. /**
  54259. * Unbind the material.
  54260. */
  54261. unbind(): void;
  54262. /**
  54263. * Bind only the world matrix to the material.
  54264. * @param world The world matrix to bind.
  54265. */
  54266. bindOnlyWorldMatrix(world: Matrix): void;
  54267. /**
  54268. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54269. * @param world The world matrix to bind.
  54270. * @param subMesh The submesh to bind for.
  54271. */
  54272. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54273. /**
  54274. * Checks to see if a texture is used in the material.
  54275. * @param texture - Base texture to use.
  54276. * @returns - Boolean specifying if a texture is used in the material.
  54277. */
  54278. hasTexture(texture: BaseTexture): boolean;
  54279. /**
  54280. * Dispose the material.
  54281. * @param forceDisposeEffect Force disposal of the associated effect.
  54282. * @param forceDisposeTextures Force disposal of the associated textures.
  54283. */
  54284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54285. /**
  54286. * Clones the material.
  54287. * @param name The cloned name.
  54288. * @returns The cloned material.
  54289. */
  54290. clone(name: string): BackgroundMaterial;
  54291. /**
  54292. * Serializes the current material to its JSON representation.
  54293. * @returns The JSON representation.
  54294. */
  54295. serialize(): any;
  54296. /**
  54297. * Gets the class name of the material
  54298. * @returns "BackgroundMaterial"
  54299. */
  54300. getClassName(): string;
  54301. /**
  54302. * Parse a JSON input to create back a background material.
  54303. * @param source The JSON data to parse
  54304. * @param scene The scene to create the parsed material in
  54305. * @param rootUrl The root url of the assets the material depends upon
  54306. * @returns the instantiated BackgroundMaterial.
  54307. */
  54308. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54309. }
  54310. }
  54311. declare module BABYLON {
  54312. /**
  54313. * Represents the different options available during the creation of
  54314. * a Environment helper.
  54315. *
  54316. * This can control the default ground, skybox and image processing setup of your scene.
  54317. */
  54318. export interface IEnvironmentHelperOptions {
  54319. /**
  54320. * Specifies whether or not to create a ground.
  54321. * True by default.
  54322. */
  54323. createGround: boolean;
  54324. /**
  54325. * Specifies the ground size.
  54326. * 15 by default.
  54327. */
  54328. groundSize: number;
  54329. /**
  54330. * The texture used on the ground for the main color.
  54331. * Comes from the BabylonJS CDN by default.
  54332. *
  54333. * Remarks: Can be either a texture or a url.
  54334. */
  54335. groundTexture: string | BaseTexture;
  54336. /**
  54337. * The color mixed in the ground texture by default.
  54338. * BabylonJS clearColor by default.
  54339. */
  54340. groundColor: Color3;
  54341. /**
  54342. * Specifies the ground opacity.
  54343. * 1 by default.
  54344. */
  54345. groundOpacity: number;
  54346. /**
  54347. * Enables the ground to receive shadows.
  54348. * True by default.
  54349. */
  54350. enableGroundShadow: boolean;
  54351. /**
  54352. * Helps preventing the shadow to be fully black on the ground.
  54353. * 0.5 by default.
  54354. */
  54355. groundShadowLevel: number;
  54356. /**
  54357. * Creates a mirror texture attach to the ground.
  54358. * false by default.
  54359. */
  54360. enableGroundMirror: boolean;
  54361. /**
  54362. * Specifies the ground mirror size ratio.
  54363. * 0.3 by default as the default kernel is 64.
  54364. */
  54365. groundMirrorSizeRatio: number;
  54366. /**
  54367. * Specifies the ground mirror blur kernel size.
  54368. * 64 by default.
  54369. */
  54370. groundMirrorBlurKernel: number;
  54371. /**
  54372. * Specifies the ground mirror visibility amount.
  54373. * 1 by default
  54374. */
  54375. groundMirrorAmount: number;
  54376. /**
  54377. * Specifies the ground mirror reflectance weight.
  54378. * This uses the standard weight of the background material to setup the fresnel effect
  54379. * of the mirror.
  54380. * 1 by default.
  54381. */
  54382. groundMirrorFresnelWeight: number;
  54383. /**
  54384. * Specifies the ground mirror Falloff distance.
  54385. * This can helps reducing the size of the reflection.
  54386. * 0 by Default.
  54387. */
  54388. groundMirrorFallOffDistance: number;
  54389. /**
  54390. * Specifies the ground mirror texture type.
  54391. * Unsigned Int by Default.
  54392. */
  54393. groundMirrorTextureType: number;
  54394. /**
  54395. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54396. * the shown objects.
  54397. */
  54398. groundYBias: number;
  54399. /**
  54400. * Specifies whether or not to create a skybox.
  54401. * True by default.
  54402. */
  54403. createSkybox: boolean;
  54404. /**
  54405. * Specifies the skybox size.
  54406. * 20 by default.
  54407. */
  54408. skyboxSize: number;
  54409. /**
  54410. * The texture used on the skybox for the main color.
  54411. * Comes from the BabylonJS CDN by default.
  54412. *
  54413. * Remarks: Can be either a texture or a url.
  54414. */
  54415. skyboxTexture: string | BaseTexture;
  54416. /**
  54417. * The color mixed in the skybox texture by default.
  54418. * BabylonJS clearColor by default.
  54419. */
  54420. skyboxColor: Color3;
  54421. /**
  54422. * The background rotation around the Y axis of the scene.
  54423. * This helps aligning the key lights of your scene with the background.
  54424. * 0 by default.
  54425. */
  54426. backgroundYRotation: number;
  54427. /**
  54428. * Compute automatically the size of the elements to best fit with the scene.
  54429. */
  54430. sizeAuto: boolean;
  54431. /**
  54432. * Default position of the rootMesh if autoSize is not true.
  54433. */
  54434. rootPosition: Vector3;
  54435. /**
  54436. * Sets up the image processing in the scene.
  54437. * true by default.
  54438. */
  54439. setupImageProcessing: boolean;
  54440. /**
  54441. * The texture used as your environment texture in the scene.
  54442. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54443. *
  54444. * Remarks: Can be either a texture or a url.
  54445. */
  54446. environmentTexture: string | BaseTexture;
  54447. /**
  54448. * The value of the exposure to apply to the scene.
  54449. * 0.6 by default if setupImageProcessing is true.
  54450. */
  54451. cameraExposure: number;
  54452. /**
  54453. * The value of the contrast to apply to the scene.
  54454. * 1.6 by default if setupImageProcessing is true.
  54455. */
  54456. cameraContrast: number;
  54457. /**
  54458. * Specifies whether or not tonemapping should be enabled in the scene.
  54459. * true by default if setupImageProcessing is true.
  54460. */
  54461. toneMappingEnabled: boolean;
  54462. }
  54463. /**
  54464. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54465. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54466. * It also helps with the default setup of your imageProcessing configuration.
  54467. */
  54468. export class EnvironmentHelper {
  54469. /**
  54470. * Default ground texture URL.
  54471. */
  54472. private static _groundTextureCDNUrl;
  54473. /**
  54474. * Default skybox texture URL.
  54475. */
  54476. private static _skyboxTextureCDNUrl;
  54477. /**
  54478. * Default environment texture URL.
  54479. */
  54480. private static _environmentTextureCDNUrl;
  54481. /**
  54482. * Creates the default options for the helper.
  54483. */
  54484. private static _getDefaultOptions;
  54485. private _rootMesh;
  54486. /**
  54487. * Gets the root mesh created by the helper.
  54488. */
  54489. get rootMesh(): Mesh;
  54490. private _skybox;
  54491. /**
  54492. * Gets the skybox created by the helper.
  54493. */
  54494. get skybox(): Nullable<Mesh>;
  54495. private _skyboxTexture;
  54496. /**
  54497. * Gets the skybox texture created by the helper.
  54498. */
  54499. get skyboxTexture(): Nullable<BaseTexture>;
  54500. private _skyboxMaterial;
  54501. /**
  54502. * Gets the skybox material created by the helper.
  54503. */
  54504. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54505. private _ground;
  54506. /**
  54507. * Gets the ground mesh created by the helper.
  54508. */
  54509. get ground(): Nullable<Mesh>;
  54510. private _groundTexture;
  54511. /**
  54512. * Gets the ground texture created by the helper.
  54513. */
  54514. get groundTexture(): Nullable<BaseTexture>;
  54515. private _groundMirror;
  54516. /**
  54517. * Gets the ground mirror created by the helper.
  54518. */
  54519. get groundMirror(): Nullable<MirrorTexture>;
  54520. /**
  54521. * Gets the ground mirror render list to helps pushing the meshes
  54522. * you wish in the ground reflection.
  54523. */
  54524. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54525. private _groundMaterial;
  54526. /**
  54527. * Gets the ground material created by the helper.
  54528. */
  54529. get groundMaterial(): Nullable<BackgroundMaterial>;
  54530. /**
  54531. * Stores the creation options.
  54532. */
  54533. private readonly _scene;
  54534. private _options;
  54535. /**
  54536. * This observable will be notified with any error during the creation of the environment,
  54537. * mainly texture creation errors.
  54538. */
  54539. onErrorObservable: Observable<{
  54540. message?: string;
  54541. exception?: any;
  54542. }>;
  54543. /**
  54544. * constructor
  54545. * @param options Defines the options we want to customize the helper
  54546. * @param scene The scene to add the material to
  54547. */
  54548. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54549. /**
  54550. * Updates the background according to the new options
  54551. * @param options
  54552. */
  54553. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54554. /**
  54555. * Sets the primary color of all the available elements.
  54556. * @param color the main color to affect to the ground and the background
  54557. */
  54558. setMainColor(color: Color3): void;
  54559. /**
  54560. * Setup the image processing according to the specified options.
  54561. */
  54562. private _setupImageProcessing;
  54563. /**
  54564. * Setup the environment texture according to the specified options.
  54565. */
  54566. private _setupEnvironmentTexture;
  54567. /**
  54568. * Setup the background according to the specified options.
  54569. */
  54570. private _setupBackground;
  54571. /**
  54572. * Get the scene sizes according to the setup.
  54573. */
  54574. private _getSceneSize;
  54575. /**
  54576. * Setup the ground according to the specified options.
  54577. */
  54578. private _setupGround;
  54579. /**
  54580. * Setup the ground material according to the specified options.
  54581. */
  54582. private _setupGroundMaterial;
  54583. /**
  54584. * Setup the ground diffuse texture according to the specified options.
  54585. */
  54586. private _setupGroundDiffuseTexture;
  54587. /**
  54588. * Setup the ground mirror texture according to the specified options.
  54589. */
  54590. private _setupGroundMirrorTexture;
  54591. /**
  54592. * Setup the ground to receive the mirror texture.
  54593. */
  54594. private _setupMirrorInGroundMaterial;
  54595. /**
  54596. * Setup the skybox according to the specified options.
  54597. */
  54598. private _setupSkybox;
  54599. /**
  54600. * Setup the skybox material according to the specified options.
  54601. */
  54602. private _setupSkyboxMaterial;
  54603. /**
  54604. * Setup the skybox reflection texture according to the specified options.
  54605. */
  54606. private _setupSkyboxReflectionTexture;
  54607. private _errorHandler;
  54608. /**
  54609. * Dispose all the elements created by the Helper.
  54610. */
  54611. dispose(): void;
  54612. }
  54613. }
  54614. declare module BABYLON {
  54615. /**
  54616. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54617. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54618. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54619. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54620. */
  54621. export class PhotoDome extends TransformNode {
  54622. /**
  54623. * Define the image as a Monoscopic panoramic 360 image.
  54624. */
  54625. static readonly MODE_MONOSCOPIC: number;
  54626. /**
  54627. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54628. */
  54629. static readonly MODE_TOPBOTTOM: number;
  54630. /**
  54631. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54632. */
  54633. static readonly MODE_SIDEBYSIDE: number;
  54634. private _useDirectMapping;
  54635. /**
  54636. * The texture being displayed on the sphere
  54637. */
  54638. protected _photoTexture: Texture;
  54639. /**
  54640. * Gets or sets the texture being displayed on the sphere
  54641. */
  54642. get photoTexture(): Texture;
  54643. set photoTexture(value: Texture);
  54644. /**
  54645. * Observable raised when an error occured while loading the 360 image
  54646. */
  54647. onLoadErrorObservable: Observable<string>;
  54648. /**
  54649. * The skybox material
  54650. */
  54651. protected _material: BackgroundMaterial;
  54652. /**
  54653. * The surface used for the skybox
  54654. */
  54655. protected _mesh: Mesh;
  54656. /**
  54657. * Gets the mesh used for the skybox.
  54658. */
  54659. get mesh(): Mesh;
  54660. /**
  54661. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54662. * Also see the options.resolution property.
  54663. */
  54664. get fovMultiplier(): number;
  54665. set fovMultiplier(value: number);
  54666. private _imageMode;
  54667. /**
  54668. * Gets or set the current video mode for the video. It can be:
  54669. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54670. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54671. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54672. */
  54673. get imageMode(): number;
  54674. set imageMode(value: number);
  54675. /**
  54676. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54677. * @param name Element's name, child elements will append suffixes for their own names.
  54678. * @param urlsOfPhoto defines the url of the photo to display
  54679. * @param options defines an object containing optional or exposed sub element properties
  54680. * @param onError defines a callback called when an error occured while loading the texture
  54681. */
  54682. constructor(name: string, urlOfPhoto: string, options: {
  54683. resolution?: number;
  54684. size?: number;
  54685. useDirectMapping?: boolean;
  54686. faceForward?: boolean;
  54687. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54688. private _onBeforeCameraRenderObserver;
  54689. private _changeImageMode;
  54690. /**
  54691. * Releases resources associated with this node.
  54692. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54693. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54694. */
  54695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54696. }
  54697. }
  54698. declare module BABYLON {
  54699. /**
  54700. * Class used to host RGBD texture specific utilities
  54701. */
  54702. export class RGBDTextureTools {
  54703. /**
  54704. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54705. * @param texture the texture to expand.
  54706. */
  54707. static ExpandRGBDTexture(texture: Texture): void;
  54708. }
  54709. }
  54710. declare module BABYLON {
  54711. /**
  54712. * Class used to host texture specific utilities
  54713. */
  54714. export class BRDFTextureTools {
  54715. /**
  54716. * Prevents texture cache collision
  54717. */
  54718. private static _instanceNumber;
  54719. /**
  54720. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54721. * @param scene defines the hosting scene
  54722. * @returns the environment BRDF texture
  54723. */
  54724. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54725. private static _environmentBRDFBase64Texture;
  54726. }
  54727. }
  54728. declare module BABYLON {
  54729. /**
  54730. * @hidden
  54731. */
  54732. export interface IMaterialClearCoatDefines {
  54733. CLEARCOAT: boolean;
  54734. CLEARCOAT_DEFAULTIOR: boolean;
  54735. CLEARCOAT_TEXTURE: boolean;
  54736. CLEARCOAT_TEXTUREDIRECTUV: number;
  54737. CLEARCOAT_BUMP: boolean;
  54738. CLEARCOAT_BUMPDIRECTUV: number;
  54739. CLEARCOAT_TINT: boolean;
  54740. CLEARCOAT_TINT_TEXTURE: boolean;
  54741. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54742. /** @hidden */
  54743. _areTexturesDirty: boolean;
  54744. }
  54745. /**
  54746. * Define the code related to the clear coat parameters of the pbr material.
  54747. */
  54748. export class PBRClearCoatConfiguration {
  54749. /**
  54750. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54751. * The default fits with a polyurethane material.
  54752. */
  54753. private static readonly _DefaultIndexOfRefraction;
  54754. private _isEnabled;
  54755. /**
  54756. * Defines if the clear coat is enabled in the material.
  54757. */
  54758. isEnabled: boolean;
  54759. /**
  54760. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54761. */
  54762. intensity: number;
  54763. /**
  54764. * Defines the clear coat layer roughness.
  54765. */
  54766. roughness: number;
  54767. private _indexOfRefraction;
  54768. /**
  54769. * Defines the index of refraction of the clear coat.
  54770. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54771. * The default fits with a polyurethane material.
  54772. * Changing the default value is more performance intensive.
  54773. */
  54774. indexOfRefraction: number;
  54775. private _texture;
  54776. /**
  54777. * Stores the clear coat values in a texture.
  54778. */
  54779. texture: Nullable<BaseTexture>;
  54780. private _bumpTexture;
  54781. /**
  54782. * Define the clear coat specific bump texture.
  54783. */
  54784. bumpTexture: Nullable<BaseTexture>;
  54785. private _isTintEnabled;
  54786. /**
  54787. * Defines if the clear coat tint is enabled in the material.
  54788. */
  54789. isTintEnabled: boolean;
  54790. /**
  54791. * Defines the clear coat tint of the material.
  54792. * This is only use if tint is enabled
  54793. */
  54794. tintColor: Color3;
  54795. /**
  54796. * Defines the distance at which the tint color should be found in the
  54797. * clear coat media.
  54798. * This is only use if tint is enabled
  54799. */
  54800. tintColorAtDistance: number;
  54801. /**
  54802. * Defines the clear coat layer thickness.
  54803. * This is only use if tint is enabled
  54804. */
  54805. tintThickness: number;
  54806. private _tintTexture;
  54807. /**
  54808. * Stores the clear tint values in a texture.
  54809. * rgb is tint
  54810. * a is a thickness factor
  54811. */
  54812. tintTexture: Nullable<BaseTexture>;
  54813. /** @hidden */
  54814. private _internalMarkAllSubMeshesAsTexturesDirty;
  54815. /** @hidden */
  54816. _markAllSubMeshesAsTexturesDirty(): void;
  54817. /**
  54818. * Instantiate a new istance of clear coat configuration.
  54819. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54820. */
  54821. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54822. /**
  54823. * Gets wehter the submesh is ready to be used or not.
  54824. * @param defines the list of "defines" to update.
  54825. * @param scene defines the scene the material belongs to.
  54826. * @param engine defines the engine the material belongs to.
  54827. * @param disableBumpMap defines wether the material disables bump or not.
  54828. * @returns - boolean indicating that the submesh is ready or not.
  54829. */
  54830. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54831. /**
  54832. * Checks to see if a texture is used in the material.
  54833. * @param defines the list of "defines" to update.
  54834. * @param scene defines the scene to the material belongs to.
  54835. */
  54836. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54837. /**
  54838. * Binds the material data.
  54839. * @param uniformBuffer defines the Uniform buffer to fill in.
  54840. * @param scene defines the scene the material belongs to.
  54841. * @param engine defines the engine the material belongs to.
  54842. * @param disableBumpMap defines wether the material disables bump or not.
  54843. * @param isFrozen defines wether the material is frozen or not.
  54844. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54845. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54846. */
  54847. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54848. /**
  54849. * Checks to see if a texture is used in the material.
  54850. * @param texture - Base texture to use.
  54851. * @returns - Boolean specifying if a texture is used in the material.
  54852. */
  54853. hasTexture(texture: BaseTexture): boolean;
  54854. /**
  54855. * Returns an array of the actively used textures.
  54856. * @param activeTextures Array of BaseTextures
  54857. */
  54858. getActiveTextures(activeTextures: BaseTexture[]): void;
  54859. /**
  54860. * Returns the animatable textures.
  54861. * @param animatables Array of animatable textures.
  54862. */
  54863. getAnimatables(animatables: IAnimatable[]): void;
  54864. /**
  54865. * Disposes the resources of the material.
  54866. * @param forceDisposeTextures - Forces the disposal of all textures.
  54867. */
  54868. dispose(forceDisposeTextures?: boolean): void;
  54869. /**
  54870. * Get the current class name of the texture useful for serialization or dynamic coding.
  54871. * @returns "PBRClearCoatConfiguration"
  54872. */
  54873. getClassName(): string;
  54874. /**
  54875. * Add fallbacks to the effect fallbacks list.
  54876. * @param defines defines the Base texture to use.
  54877. * @param fallbacks defines the current fallback list.
  54878. * @param currentRank defines the current fallback rank.
  54879. * @returns the new fallback rank.
  54880. */
  54881. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54882. /**
  54883. * Add the required uniforms to the current list.
  54884. * @param uniforms defines the current uniform list.
  54885. */
  54886. static AddUniforms(uniforms: string[]): void;
  54887. /**
  54888. * Add the required samplers to the current list.
  54889. * @param samplers defines the current sampler list.
  54890. */
  54891. static AddSamplers(samplers: string[]): void;
  54892. /**
  54893. * Add the required uniforms to the current buffer.
  54894. * @param uniformBuffer defines the current uniform buffer.
  54895. */
  54896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54897. /**
  54898. * Makes a duplicate of the current configuration into another one.
  54899. * @param clearCoatConfiguration define the config where to copy the info
  54900. */
  54901. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54902. /**
  54903. * Serializes this clear coat configuration.
  54904. * @returns - An object with the serialized config.
  54905. */
  54906. serialize(): any;
  54907. /**
  54908. * Parses a anisotropy Configuration from a serialized object.
  54909. * @param source - Serialized object.
  54910. * @param scene Defines the scene we are parsing for
  54911. * @param rootUrl Defines the rootUrl to load from
  54912. */
  54913. parse(source: any, scene: Scene, rootUrl: string): void;
  54914. }
  54915. }
  54916. declare module BABYLON {
  54917. /**
  54918. * @hidden
  54919. */
  54920. export interface IMaterialAnisotropicDefines {
  54921. ANISOTROPIC: boolean;
  54922. ANISOTROPIC_TEXTURE: boolean;
  54923. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54924. MAINUV1: boolean;
  54925. _areTexturesDirty: boolean;
  54926. _needUVs: boolean;
  54927. }
  54928. /**
  54929. * Define the code related to the anisotropic parameters of the pbr material.
  54930. */
  54931. export class PBRAnisotropicConfiguration {
  54932. private _isEnabled;
  54933. /**
  54934. * Defines if the anisotropy is enabled in the material.
  54935. */
  54936. isEnabled: boolean;
  54937. /**
  54938. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54939. */
  54940. intensity: number;
  54941. /**
  54942. * Defines if the effect is along the tangents, bitangents or in between.
  54943. * By default, the effect is "strectching" the highlights along the tangents.
  54944. */
  54945. direction: Vector2;
  54946. private _texture;
  54947. /**
  54948. * Stores the anisotropy values in a texture.
  54949. * rg is direction (like normal from -1 to 1)
  54950. * b is a intensity
  54951. */
  54952. texture: Nullable<BaseTexture>;
  54953. /** @hidden */
  54954. private _internalMarkAllSubMeshesAsTexturesDirty;
  54955. /** @hidden */
  54956. _markAllSubMeshesAsTexturesDirty(): void;
  54957. /**
  54958. * Instantiate a new istance of anisotropy configuration.
  54959. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54960. */
  54961. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54962. /**
  54963. * Specifies that the submesh is ready to be used.
  54964. * @param defines the list of "defines" to update.
  54965. * @param scene defines the scene the material belongs to.
  54966. * @returns - boolean indicating that the submesh is ready or not.
  54967. */
  54968. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54969. /**
  54970. * Checks to see if a texture is used in the material.
  54971. * @param defines the list of "defines" to update.
  54972. * @param mesh the mesh we are preparing the defines for.
  54973. * @param scene defines the scene the material belongs to.
  54974. */
  54975. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54976. /**
  54977. * Binds the material data.
  54978. * @param uniformBuffer defines the Uniform buffer to fill in.
  54979. * @param scene defines the scene the material belongs to.
  54980. * @param isFrozen defines wether the material is frozen or not.
  54981. */
  54982. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54983. /**
  54984. * Checks to see if a texture is used in the material.
  54985. * @param texture - Base texture to use.
  54986. * @returns - Boolean specifying if a texture is used in the material.
  54987. */
  54988. hasTexture(texture: BaseTexture): boolean;
  54989. /**
  54990. * Returns an array of the actively used textures.
  54991. * @param activeTextures Array of BaseTextures
  54992. */
  54993. getActiveTextures(activeTextures: BaseTexture[]): void;
  54994. /**
  54995. * Returns the animatable textures.
  54996. * @param animatables Array of animatable textures.
  54997. */
  54998. getAnimatables(animatables: IAnimatable[]): void;
  54999. /**
  55000. * Disposes the resources of the material.
  55001. * @param forceDisposeTextures - Forces the disposal of all textures.
  55002. */
  55003. dispose(forceDisposeTextures?: boolean): void;
  55004. /**
  55005. * Get the current class name of the texture useful for serialization or dynamic coding.
  55006. * @returns "PBRAnisotropicConfiguration"
  55007. */
  55008. getClassName(): string;
  55009. /**
  55010. * Add fallbacks to the effect fallbacks list.
  55011. * @param defines defines the Base texture to use.
  55012. * @param fallbacks defines the current fallback list.
  55013. * @param currentRank defines the current fallback rank.
  55014. * @returns the new fallback rank.
  55015. */
  55016. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55017. /**
  55018. * Add the required uniforms to the current list.
  55019. * @param uniforms defines the current uniform list.
  55020. */
  55021. static AddUniforms(uniforms: string[]): void;
  55022. /**
  55023. * Add the required uniforms to the current buffer.
  55024. * @param uniformBuffer defines the current uniform buffer.
  55025. */
  55026. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55027. /**
  55028. * Add the required samplers to the current list.
  55029. * @param samplers defines the current sampler list.
  55030. */
  55031. static AddSamplers(samplers: string[]): void;
  55032. /**
  55033. * Makes a duplicate of the current configuration into another one.
  55034. * @param anisotropicConfiguration define the config where to copy the info
  55035. */
  55036. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55037. /**
  55038. * Serializes this anisotropy configuration.
  55039. * @returns - An object with the serialized config.
  55040. */
  55041. serialize(): any;
  55042. /**
  55043. * Parses a anisotropy Configuration from a serialized object.
  55044. * @param source - Serialized object.
  55045. * @param scene Defines the scene we are parsing for
  55046. * @param rootUrl Defines the rootUrl to load from
  55047. */
  55048. parse(source: any, scene: Scene, rootUrl: string): void;
  55049. }
  55050. }
  55051. declare module BABYLON {
  55052. /**
  55053. * @hidden
  55054. */
  55055. export interface IMaterialBRDFDefines {
  55056. BRDF_V_HEIGHT_CORRELATED: boolean;
  55057. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55058. SPHERICAL_HARMONICS: boolean;
  55059. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55060. /** @hidden */
  55061. _areMiscDirty: boolean;
  55062. }
  55063. /**
  55064. * Define the code related to the BRDF parameters of the pbr material.
  55065. */
  55066. export class PBRBRDFConfiguration {
  55067. /**
  55068. * Default value used for the energy conservation.
  55069. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55070. */
  55071. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55072. /**
  55073. * Default value used for the Smith Visibility Height Correlated mode.
  55074. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55075. */
  55076. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55077. /**
  55078. * Default value used for the IBL diffuse part.
  55079. * This can help switching back to the polynomials mode globally which is a tiny bit
  55080. * less GPU intensive at the drawback of a lower quality.
  55081. */
  55082. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55083. /**
  55084. * Default value used for activating energy conservation for the specular workflow.
  55085. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55086. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55087. */
  55088. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55089. private _useEnergyConservation;
  55090. /**
  55091. * Defines if the material uses energy conservation.
  55092. */
  55093. useEnergyConservation: boolean;
  55094. private _useSmithVisibilityHeightCorrelated;
  55095. /**
  55096. * LEGACY Mode set to false
  55097. * Defines if the material uses height smith correlated visibility term.
  55098. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55099. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55100. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55101. * Not relying on height correlated will also disable energy conservation.
  55102. */
  55103. useSmithVisibilityHeightCorrelated: boolean;
  55104. private _useSphericalHarmonics;
  55105. /**
  55106. * LEGACY Mode set to false
  55107. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55108. * diffuse part of the IBL.
  55109. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55110. * to the ground truth.
  55111. */
  55112. useSphericalHarmonics: boolean;
  55113. private _useSpecularGlossinessInputEnergyConservation;
  55114. /**
  55115. * Defines if the material uses energy conservation, when the specular workflow is active.
  55116. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55117. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55118. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55119. */
  55120. useSpecularGlossinessInputEnergyConservation: boolean;
  55121. /** @hidden */
  55122. private _internalMarkAllSubMeshesAsMiscDirty;
  55123. /** @hidden */
  55124. _markAllSubMeshesAsMiscDirty(): void;
  55125. /**
  55126. * Instantiate a new istance of clear coat configuration.
  55127. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55128. */
  55129. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55130. /**
  55131. * Checks to see if a texture is used in the material.
  55132. * @param defines the list of "defines" to update.
  55133. */
  55134. prepareDefines(defines: IMaterialBRDFDefines): void;
  55135. /**
  55136. * Get the current class name of the texture useful for serialization or dynamic coding.
  55137. * @returns "PBRClearCoatConfiguration"
  55138. */
  55139. getClassName(): string;
  55140. /**
  55141. * Makes a duplicate of the current configuration into another one.
  55142. * @param brdfConfiguration define the config where to copy the info
  55143. */
  55144. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55145. /**
  55146. * Serializes this BRDF configuration.
  55147. * @returns - An object with the serialized config.
  55148. */
  55149. serialize(): any;
  55150. /**
  55151. * Parses a anisotropy Configuration from a serialized object.
  55152. * @param source - Serialized object.
  55153. * @param scene Defines the scene we are parsing for
  55154. * @param rootUrl Defines the rootUrl to load from
  55155. */
  55156. parse(source: any, scene: Scene, rootUrl: string): void;
  55157. }
  55158. }
  55159. declare module BABYLON {
  55160. /**
  55161. * @hidden
  55162. */
  55163. export interface IMaterialSheenDefines {
  55164. SHEEN: boolean;
  55165. SHEEN_TEXTURE: boolean;
  55166. SHEEN_TEXTUREDIRECTUV: number;
  55167. SHEEN_LINKWITHALBEDO: boolean;
  55168. SHEEN_ROUGHNESS: boolean;
  55169. SHEEN_ALBEDOSCALING: boolean;
  55170. /** @hidden */
  55171. _areTexturesDirty: boolean;
  55172. }
  55173. /**
  55174. * Define the code related to the Sheen parameters of the pbr material.
  55175. */
  55176. export class PBRSheenConfiguration {
  55177. private _isEnabled;
  55178. /**
  55179. * Defines if the material uses sheen.
  55180. */
  55181. isEnabled: boolean;
  55182. private _linkSheenWithAlbedo;
  55183. /**
  55184. * Defines if the sheen is linked to the sheen color.
  55185. */
  55186. linkSheenWithAlbedo: boolean;
  55187. /**
  55188. * Defines the sheen intensity.
  55189. */
  55190. intensity: number;
  55191. /**
  55192. * Defines the sheen color.
  55193. */
  55194. color: Color3;
  55195. private _texture;
  55196. /**
  55197. * Stores the sheen tint values in a texture.
  55198. * rgb is tint
  55199. * a is a intensity or roughness if roughness has been defined
  55200. */
  55201. texture: Nullable<BaseTexture>;
  55202. private _roughness;
  55203. /**
  55204. * Defines the sheen roughness.
  55205. * It is not taken into account if linkSheenWithAlbedo is true.
  55206. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55207. */
  55208. roughness: Nullable<number>;
  55209. private _albedoScaling;
  55210. /**
  55211. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55212. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55213. * making it easier to setup and tweak the effect
  55214. */
  55215. albedoScaling: boolean;
  55216. /** @hidden */
  55217. private _internalMarkAllSubMeshesAsTexturesDirty;
  55218. /** @hidden */
  55219. _markAllSubMeshesAsTexturesDirty(): void;
  55220. /**
  55221. * Instantiate a new istance of clear coat configuration.
  55222. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55223. */
  55224. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55225. /**
  55226. * Specifies that the submesh is ready to be used.
  55227. * @param defines the list of "defines" to update.
  55228. * @param scene defines the scene the material belongs to.
  55229. * @returns - boolean indicating that the submesh is ready or not.
  55230. */
  55231. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55232. /**
  55233. * Checks to see if a texture is used in the material.
  55234. * @param defines the list of "defines" to update.
  55235. * @param scene defines the scene the material belongs to.
  55236. */
  55237. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55238. /**
  55239. * Binds the material data.
  55240. * @param uniformBuffer defines the Uniform buffer to fill in.
  55241. * @param scene defines the scene the material belongs to.
  55242. * @param isFrozen defines wether the material is frozen or not.
  55243. */
  55244. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55245. /**
  55246. * Checks to see if a texture is used in the material.
  55247. * @param texture - Base texture to use.
  55248. * @returns - Boolean specifying if a texture is used in the material.
  55249. */
  55250. hasTexture(texture: BaseTexture): boolean;
  55251. /**
  55252. * Returns an array of the actively used textures.
  55253. * @param activeTextures Array of BaseTextures
  55254. */
  55255. getActiveTextures(activeTextures: BaseTexture[]): void;
  55256. /**
  55257. * Returns the animatable textures.
  55258. * @param animatables Array of animatable textures.
  55259. */
  55260. getAnimatables(animatables: IAnimatable[]): void;
  55261. /**
  55262. * Disposes the resources of the material.
  55263. * @param forceDisposeTextures - Forces the disposal of all textures.
  55264. */
  55265. dispose(forceDisposeTextures?: boolean): void;
  55266. /**
  55267. * Get the current class name of the texture useful for serialization or dynamic coding.
  55268. * @returns "PBRSheenConfiguration"
  55269. */
  55270. getClassName(): string;
  55271. /**
  55272. * Add fallbacks to the effect fallbacks list.
  55273. * @param defines defines the Base texture to use.
  55274. * @param fallbacks defines the current fallback list.
  55275. * @param currentRank defines the current fallback rank.
  55276. * @returns the new fallback rank.
  55277. */
  55278. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55279. /**
  55280. * Add the required uniforms to the current list.
  55281. * @param uniforms defines the current uniform list.
  55282. */
  55283. static AddUniforms(uniforms: string[]): void;
  55284. /**
  55285. * Add the required uniforms to the current buffer.
  55286. * @param uniformBuffer defines the current uniform buffer.
  55287. */
  55288. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55289. /**
  55290. * Add the required samplers to the current list.
  55291. * @param samplers defines the current sampler list.
  55292. */
  55293. static AddSamplers(samplers: string[]): void;
  55294. /**
  55295. * Makes a duplicate of the current configuration into another one.
  55296. * @param sheenConfiguration define the config where to copy the info
  55297. */
  55298. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55299. /**
  55300. * Serializes this BRDF configuration.
  55301. * @returns - An object with the serialized config.
  55302. */
  55303. serialize(): any;
  55304. /**
  55305. * Parses a anisotropy Configuration from a serialized object.
  55306. * @param source - Serialized object.
  55307. * @param scene Defines the scene we are parsing for
  55308. * @param rootUrl Defines the rootUrl to load from
  55309. */
  55310. parse(source: any, scene: Scene, rootUrl: string): void;
  55311. }
  55312. }
  55313. declare module BABYLON {
  55314. /**
  55315. * @hidden
  55316. */
  55317. export interface IMaterialSubSurfaceDefines {
  55318. SUBSURFACE: boolean;
  55319. SS_REFRACTION: boolean;
  55320. SS_TRANSLUCENCY: boolean;
  55321. SS_SCATTERING: boolean;
  55322. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55323. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55324. SS_REFRACTIONMAP_3D: boolean;
  55325. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55326. SS_LODINREFRACTIONALPHA: boolean;
  55327. SS_GAMMAREFRACTION: boolean;
  55328. SS_RGBDREFRACTION: boolean;
  55329. SS_LINEARSPECULARREFRACTION: boolean;
  55330. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55331. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55332. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55333. /** @hidden */
  55334. _areTexturesDirty: boolean;
  55335. }
  55336. /**
  55337. * Define the code related to the sub surface parameters of the pbr material.
  55338. */
  55339. export class PBRSubSurfaceConfiguration {
  55340. private _isRefractionEnabled;
  55341. /**
  55342. * Defines if the refraction is enabled in the material.
  55343. */
  55344. isRefractionEnabled: boolean;
  55345. private _isTranslucencyEnabled;
  55346. /**
  55347. * Defines if the translucency is enabled in the material.
  55348. */
  55349. isTranslucencyEnabled: boolean;
  55350. private _isScatteringEnabled;
  55351. /**
  55352. * Defines if the sub surface scattering is enabled in the material.
  55353. */
  55354. isScatteringEnabled: boolean;
  55355. private _scatteringDiffusionProfileIndex;
  55356. /**
  55357. * Diffusion profile for subsurface scattering.
  55358. * Useful for better scattering in the skins or foliages.
  55359. */
  55360. get scatteringDiffusionProfile(): Nullable<Color3>;
  55361. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55362. /**
  55363. * Defines the refraction intensity of the material.
  55364. * The refraction when enabled replaces the Diffuse part of the material.
  55365. * The intensity helps transitionning between diffuse and refraction.
  55366. */
  55367. refractionIntensity: number;
  55368. /**
  55369. * Defines the translucency intensity of the material.
  55370. * When translucency has been enabled, this defines how much of the "translucency"
  55371. * is addded to the diffuse part of the material.
  55372. */
  55373. translucencyIntensity: number;
  55374. /**
  55375. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55376. */
  55377. useAlbedoToTintRefraction: boolean;
  55378. private _thicknessTexture;
  55379. /**
  55380. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55381. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55382. * 0 would mean minimumThickness
  55383. * 1 would mean maximumThickness
  55384. * The other channels might be use as a mask to vary the different effects intensity.
  55385. */
  55386. thicknessTexture: Nullable<BaseTexture>;
  55387. private _refractionTexture;
  55388. /**
  55389. * Defines the texture to use for refraction.
  55390. */
  55391. refractionTexture: Nullable<BaseTexture>;
  55392. private _indexOfRefraction;
  55393. /**
  55394. * Index of refraction of the material base layer.
  55395. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55396. *
  55397. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55398. *
  55399. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55400. */
  55401. indexOfRefraction: number;
  55402. private _volumeIndexOfRefraction;
  55403. /**
  55404. * Index of refraction of the material's volume.
  55405. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55406. *
  55407. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55408. * the volume will use the same IOR as the surface.
  55409. */
  55410. get volumeIndexOfRefraction(): number;
  55411. set volumeIndexOfRefraction(value: number);
  55412. private _invertRefractionY;
  55413. /**
  55414. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55415. */
  55416. invertRefractionY: boolean;
  55417. private _linkRefractionWithTransparency;
  55418. /**
  55419. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55420. * Materials half opaque for instance using refraction could benefit from this control.
  55421. */
  55422. linkRefractionWithTransparency: boolean;
  55423. /**
  55424. * Defines the minimum thickness stored in the thickness map.
  55425. * If no thickness map is defined, this value will be used to simulate thickness.
  55426. */
  55427. minimumThickness: number;
  55428. /**
  55429. * Defines the maximum thickness stored in the thickness map.
  55430. */
  55431. maximumThickness: number;
  55432. /**
  55433. * Defines the volume tint of the material.
  55434. * This is used for both translucency and scattering.
  55435. */
  55436. tintColor: Color3;
  55437. /**
  55438. * Defines the distance at which the tint color should be found in the media.
  55439. * This is used for refraction only.
  55440. */
  55441. tintColorAtDistance: number;
  55442. /**
  55443. * Defines how far each channel transmit through the media.
  55444. * It is defined as a color to simplify it selection.
  55445. */
  55446. diffusionDistance: Color3;
  55447. private _useMaskFromThicknessTexture;
  55448. /**
  55449. * Stores the intensity of the different subsurface effects in the thickness texture.
  55450. * * the green channel is the translucency intensity.
  55451. * * the blue channel is the scattering intensity.
  55452. * * the alpha channel is the refraction intensity.
  55453. */
  55454. useMaskFromThicknessTexture: boolean;
  55455. private _scene;
  55456. /** @hidden */
  55457. private _internalMarkAllSubMeshesAsTexturesDirty;
  55458. private _internalMarkScenePrePassDirty;
  55459. /** @hidden */
  55460. _markAllSubMeshesAsTexturesDirty(): void;
  55461. /** @hidden */
  55462. _markScenePrePassDirty(): void;
  55463. /**
  55464. * Instantiate a new istance of sub surface configuration.
  55465. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55466. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55467. * @param scene The scene
  55468. */
  55469. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55470. /**
  55471. * Gets wehter the submesh is ready to be used or not.
  55472. * @param defines the list of "defines" to update.
  55473. * @param scene defines the scene the material belongs to.
  55474. * @returns - boolean indicating that the submesh is ready or not.
  55475. */
  55476. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55477. /**
  55478. * Checks to see if a texture is used in the material.
  55479. * @param defines the list of "defines" to update.
  55480. * @param scene defines the scene to the material belongs to.
  55481. */
  55482. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55483. /**
  55484. * Binds the material data.
  55485. * @param uniformBuffer defines the Uniform buffer to fill in.
  55486. * @param scene defines the scene the material belongs to.
  55487. * @param engine defines the engine the material belongs to.
  55488. * @param isFrozen defines whether the material is frozen or not.
  55489. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55490. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55491. */
  55492. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55493. /**
  55494. * Unbinds the material from the mesh.
  55495. * @param activeEffect defines the effect that should be unbound from.
  55496. * @returns true if unbound, otherwise false
  55497. */
  55498. unbind(activeEffect: Effect): boolean;
  55499. /**
  55500. * Returns the texture used for refraction or null if none is used.
  55501. * @param scene defines the scene the material belongs to.
  55502. * @returns - Refraction texture if present. If no refraction texture and refraction
  55503. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55504. */
  55505. private _getRefractionTexture;
  55506. /**
  55507. * Returns true if alpha blending should be disabled.
  55508. */
  55509. get disableAlphaBlending(): boolean;
  55510. /**
  55511. * Fills the list of render target textures.
  55512. * @param renderTargets the list of render targets to update
  55513. */
  55514. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55515. /**
  55516. * Checks to see if a texture is used in the material.
  55517. * @param texture - Base texture to use.
  55518. * @returns - Boolean specifying if a texture is used in the material.
  55519. */
  55520. hasTexture(texture: BaseTexture): boolean;
  55521. /**
  55522. * Gets a boolean indicating that current material needs to register RTT
  55523. * @returns true if this uses a render target otherwise false.
  55524. */
  55525. hasRenderTargetTextures(): boolean;
  55526. /**
  55527. * Returns an array of the actively used textures.
  55528. * @param activeTextures Array of BaseTextures
  55529. */
  55530. getActiveTextures(activeTextures: BaseTexture[]): void;
  55531. /**
  55532. * Returns the animatable textures.
  55533. * @param animatables Array of animatable textures.
  55534. */
  55535. getAnimatables(animatables: IAnimatable[]): void;
  55536. /**
  55537. * Disposes the resources of the material.
  55538. * @param forceDisposeTextures - Forces the disposal of all textures.
  55539. */
  55540. dispose(forceDisposeTextures?: boolean): void;
  55541. /**
  55542. * Get the current class name of the texture useful for serialization or dynamic coding.
  55543. * @returns "PBRSubSurfaceConfiguration"
  55544. */
  55545. getClassName(): string;
  55546. /**
  55547. * Add fallbacks to the effect fallbacks list.
  55548. * @param defines defines the Base texture to use.
  55549. * @param fallbacks defines the current fallback list.
  55550. * @param currentRank defines the current fallback rank.
  55551. * @returns the new fallback rank.
  55552. */
  55553. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55554. /**
  55555. * Add the required uniforms to the current list.
  55556. * @param uniforms defines the current uniform list.
  55557. */
  55558. static AddUniforms(uniforms: string[]): void;
  55559. /**
  55560. * Add the required samplers to the current list.
  55561. * @param samplers defines the current sampler list.
  55562. */
  55563. static AddSamplers(samplers: string[]): void;
  55564. /**
  55565. * Add the required uniforms to the current buffer.
  55566. * @param uniformBuffer defines the current uniform buffer.
  55567. */
  55568. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55569. /**
  55570. * Makes a duplicate of the current configuration into another one.
  55571. * @param configuration define the config where to copy the info
  55572. */
  55573. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55574. /**
  55575. * Serializes this Sub Surface configuration.
  55576. * @returns - An object with the serialized config.
  55577. */
  55578. serialize(): any;
  55579. /**
  55580. * Parses a anisotropy Configuration from a serialized object.
  55581. * @param source - Serialized object.
  55582. * @param scene Defines the scene we are parsing for
  55583. * @param rootUrl Defines the rootUrl to load from
  55584. */
  55585. parse(source: any, scene: Scene, rootUrl: string): void;
  55586. }
  55587. }
  55588. declare module BABYLON {
  55589. /** @hidden */
  55590. export var pbrFragmentDeclaration: {
  55591. name: string;
  55592. shader: string;
  55593. };
  55594. }
  55595. declare module BABYLON {
  55596. /** @hidden */
  55597. export var pbrUboDeclaration: {
  55598. name: string;
  55599. shader: string;
  55600. };
  55601. }
  55602. declare module BABYLON {
  55603. /** @hidden */
  55604. export var pbrFragmentExtraDeclaration: {
  55605. name: string;
  55606. shader: string;
  55607. };
  55608. }
  55609. declare module BABYLON {
  55610. /** @hidden */
  55611. export var pbrFragmentSamplersDeclaration: {
  55612. name: string;
  55613. shader: string;
  55614. };
  55615. }
  55616. declare module BABYLON {
  55617. /** @hidden */
  55618. export var importanceSampling: {
  55619. name: string;
  55620. shader: string;
  55621. };
  55622. }
  55623. declare module BABYLON {
  55624. /** @hidden */
  55625. export var pbrHelperFunctions: {
  55626. name: string;
  55627. shader: string;
  55628. };
  55629. }
  55630. declare module BABYLON {
  55631. /** @hidden */
  55632. export var harmonicsFunctions: {
  55633. name: string;
  55634. shader: string;
  55635. };
  55636. }
  55637. declare module BABYLON {
  55638. /** @hidden */
  55639. export var pbrDirectLightingSetupFunctions: {
  55640. name: string;
  55641. shader: string;
  55642. };
  55643. }
  55644. declare module BABYLON {
  55645. /** @hidden */
  55646. export var pbrDirectLightingFalloffFunctions: {
  55647. name: string;
  55648. shader: string;
  55649. };
  55650. }
  55651. declare module BABYLON {
  55652. /** @hidden */
  55653. export var pbrBRDFFunctions: {
  55654. name: string;
  55655. shader: string;
  55656. };
  55657. }
  55658. declare module BABYLON {
  55659. /** @hidden */
  55660. export var hdrFilteringFunctions: {
  55661. name: string;
  55662. shader: string;
  55663. };
  55664. }
  55665. declare module BABYLON {
  55666. /** @hidden */
  55667. export var pbrDirectLightingFunctions: {
  55668. name: string;
  55669. shader: string;
  55670. };
  55671. }
  55672. declare module BABYLON {
  55673. /** @hidden */
  55674. export var pbrIBLFunctions: {
  55675. name: string;
  55676. shader: string;
  55677. };
  55678. }
  55679. declare module BABYLON {
  55680. /** @hidden */
  55681. export var pbrBlockAlbedoOpacity: {
  55682. name: string;
  55683. shader: string;
  55684. };
  55685. }
  55686. declare module BABYLON {
  55687. /** @hidden */
  55688. export var pbrBlockReflectivity: {
  55689. name: string;
  55690. shader: string;
  55691. };
  55692. }
  55693. declare module BABYLON {
  55694. /** @hidden */
  55695. export var pbrBlockAmbientOcclusion: {
  55696. name: string;
  55697. shader: string;
  55698. };
  55699. }
  55700. declare module BABYLON {
  55701. /** @hidden */
  55702. export var pbrBlockAlphaFresnel: {
  55703. name: string;
  55704. shader: string;
  55705. };
  55706. }
  55707. declare module BABYLON {
  55708. /** @hidden */
  55709. export var pbrBlockAnisotropic: {
  55710. name: string;
  55711. shader: string;
  55712. };
  55713. }
  55714. declare module BABYLON {
  55715. /** @hidden */
  55716. export var pbrBlockReflection: {
  55717. name: string;
  55718. shader: string;
  55719. };
  55720. }
  55721. declare module BABYLON {
  55722. /** @hidden */
  55723. export var pbrBlockSheen: {
  55724. name: string;
  55725. shader: string;
  55726. };
  55727. }
  55728. declare module BABYLON {
  55729. /** @hidden */
  55730. export var pbrBlockClearcoat: {
  55731. name: string;
  55732. shader: string;
  55733. };
  55734. }
  55735. declare module BABYLON {
  55736. /** @hidden */
  55737. export var pbrBlockSubSurface: {
  55738. name: string;
  55739. shader: string;
  55740. };
  55741. }
  55742. declare module BABYLON {
  55743. /** @hidden */
  55744. export var pbrBlockNormalGeometric: {
  55745. name: string;
  55746. shader: string;
  55747. };
  55748. }
  55749. declare module BABYLON {
  55750. /** @hidden */
  55751. export var pbrBlockNormalFinal: {
  55752. name: string;
  55753. shader: string;
  55754. };
  55755. }
  55756. declare module BABYLON {
  55757. /** @hidden */
  55758. export var pbrBlockLightmapInit: {
  55759. name: string;
  55760. shader: string;
  55761. };
  55762. }
  55763. declare module BABYLON {
  55764. /** @hidden */
  55765. export var pbrBlockGeometryInfo: {
  55766. name: string;
  55767. shader: string;
  55768. };
  55769. }
  55770. declare module BABYLON {
  55771. /** @hidden */
  55772. export var pbrBlockReflectance0: {
  55773. name: string;
  55774. shader: string;
  55775. };
  55776. }
  55777. declare module BABYLON {
  55778. /** @hidden */
  55779. export var pbrBlockReflectance: {
  55780. name: string;
  55781. shader: string;
  55782. };
  55783. }
  55784. declare module BABYLON {
  55785. /** @hidden */
  55786. export var pbrBlockDirectLighting: {
  55787. name: string;
  55788. shader: string;
  55789. };
  55790. }
  55791. declare module BABYLON {
  55792. /** @hidden */
  55793. export var pbrBlockFinalLitComponents: {
  55794. name: string;
  55795. shader: string;
  55796. };
  55797. }
  55798. declare module BABYLON {
  55799. /** @hidden */
  55800. export var pbrBlockFinalUnlitComponents: {
  55801. name: string;
  55802. shader: string;
  55803. };
  55804. }
  55805. declare module BABYLON {
  55806. /** @hidden */
  55807. export var pbrBlockFinalColorComposition: {
  55808. name: string;
  55809. shader: string;
  55810. };
  55811. }
  55812. declare module BABYLON {
  55813. /** @hidden */
  55814. export var pbrBlockImageProcessing: {
  55815. name: string;
  55816. shader: string;
  55817. };
  55818. }
  55819. declare module BABYLON {
  55820. /** @hidden */
  55821. export var pbrDebug: {
  55822. name: string;
  55823. shader: string;
  55824. };
  55825. }
  55826. declare module BABYLON {
  55827. /** @hidden */
  55828. export var pbrPixelShader: {
  55829. name: string;
  55830. shader: string;
  55831. };
  55832. }
  55833. declare module BABYLON {
  55834. /** @hidden */
  55835. export var pbrVertexDeclaration: {
  55836. name: string;
  55837. shader: string;
  55838. };
  55839. }
  55840. declare module BABYLON {
  55841. /** @hidden */
  55842. export var pbrVertexShader: {
  55843. name: string;
  55844. shader: string;
  55845. };
  55846. }
  55847. declare module BABYLON {
  55848. /**
  55849. * Manages the defines for the PBR Material.
  55850. * @hidden
  55851. */
  55852. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55853. PBR: boolean;
  55854. NUM_SAMPLES: string;
  55855. REALTIME_FILTERING: boolean;
  55856. MAINUV1: boolean;
  55857. MAINUV2: boolean;
  55858. UV1: boolean;
  55859. UV2: boolean;
  55860. ALBEDO: boolean;
  55861. GAMMAALBEDO: boolean;
  55862. ALBEDODIRECTUV: number;
  55863. VERTEXCOLOR: boolean;
  55864. DETAIL: boolean;
  55865. DETAILDIRECTUV: number;
  55866. DETAIL_NORMALBLENDMETHOD: number;
  55867. AMBIENT: boolean;
  55868. AMBIENTDIRECTUV: number;
  55869. AMBIENTINGRAYSCALE: boolean;
  55870. OPACITY: boolean;
  55871. VERTEXALPHA: boolean;
  55872. OPACITYDIRECTUV: number;
  55873. OPACITYRGB: boolean;
  55874. ALPHATEST: boolean;
  55875. DEPTHPREPASS: boolean;
  55876. ALPHABLEND: boolean;
  55877. ALPHAFROMALBEDO: boolean;
  55878. ALPHATESTVALUE: string;
  55879. SPECULAROVERALPHA: boolean;
  55880. RADIANCEOVERALPHA: boolean;
  55881. ALPHAFRESNEL: boolean;
  55882. LINEARALPHAFRESNEL: boolean;
  55883. PREMULTIPLYALPHA: boolean;
  55884. EMISSIVE: boolean;
  55885. EMISSIVEDIRECTUV: number;
  55886. REFLECTIVITY: boolean;
  55887. REFLECTIVITYDIRECTUV: number;
  55888. SPECULARTERM: boolean;
  55889. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55890. MICROSURFACEAUTOMATIC: boolean;
  55891. LODBASEDMICROSFURACE: boolean;
  55892. MICROSURFACEMAP: boolean;
  55893. MICROSURFACEMAPDIRECTUV: number;
  55894. METALLICWORKFLOW: boolean;
  55895. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55896. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55897. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55898. AOSTOREINMETALMAPRED: boolean;
  55899. METALLIC_REFLECTANCE: boolean;
  55900. METALLIC_REFLECTANCEDIRECTUV: number;
  55901. ENVIRONMENTBRDF: boolean;
  55902. ENVIRONMENTBRDF_RGBD: boolean;
  55903. NORMAL: boolean;
  55904. TANGENT: boolean;
  55905. BUMP: boolean;
  55906. BUMPDIRECTUV: number;
  55907. OBJECTSPACE_NORMALMAP: boolean;
  55908. PARALLAX: boolean;
  55909. PARALLAXOCCLUSION: boolean;
  55910. NORMALXYSCALE: boolean;
  55911. LIGHTMAP: boolean;
  55912. LIGHTMAPDIRECTUV: number;
  55913. USELIGHTMAPASSHADOWMAP: boolean;
  55914. GAMMALIGHTMAP: boolean;
  55915. RGBDLIGHTMAP: boolean;
  55916. REFLECTION: boolean;
  55917. REFLECTIONMAP_3D: boolean;
  55918. REFLECTIONMAP_SPHERICAL: boolean;
  55919. REFLECTIONMAP_PLANAR: boolean;
  55920. REFLECTIONMAP_CUBIC: boolean;
  55921. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55922. REFLECTIONMAP_PROJECTION: boolean;
  55923. REFLECTIONMAP_SKYBOX: boolean;
  55924. REFLECTIONMAP_EXPLICIT: boolean;
  55925. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55926. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55927. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55928. INVERTCUBICMAP: boolean;
  55929. USESPHERICALFROMREFLECTIONMAP: boolean;
  55930. USEIRRADIANCEMAP: boolean;
  55931. SPHERICAL_HARMONICS: boolean;
  55932. USESPHERICALINVERTEX: boolean;
  55933. REFLECTIONMAP_OPPOSITEZ: boolean;
  55934. LODINREFLECTIONALPHA: boolean;
  55935. GAMMAREFLECTION: boolean;
  55936. RGBDREFLECTION: boolean;
  55937. LINEARSPECULARREFLECTION: boolean;
  55938. RADIANCEOCCLUSION: boolean;
  55939. HORIZONOCCLUSION: boolean;
  55940. INSTANCES: boolean;
  55941. THIN_INSTANCES: boolean;
  55942. PREPASS: boolean;
  55943. SCENE_MRT_COUNT: number;
  55944. NUM_BONE_INFLUENCERS: number;
  55945. BonesPerMesh: number;
  55946. BONETEXTURE: boolean;
  55947. NONUNIFORMSCALING: boolean;
  55948. MORPHTARGETS: boolean;
  55949. MORPHTARGETS_NORMAL: boolean;
  55950. MORPHTARGETS_TANGENT: boolean;
  55951. MORPHTARGETS_UV: boolean;
  55952. NUM_MORPH_INFLUENCERS: number;
  55953. IMAGEPROCESSING: boolean;
  55954. VIGNETTE: boolean;
  55955. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55956. VIGNETTEBLENDMODEOPAQUE: boolean;
  55957. TONEMAPPING: boolean;
  55958. TONEMAPPING_ACES: boolean;
  55959. CONTRAST: boolean;
  55960. COLORCURVES: boolean;
  55961. COLORGRADING: boolean;
  55962. COLORGRADING3D: boolean;
  55963. SAMPLER3DGREENDEPTH: boolean;
  55964. SAMPLER3DBGRMAP: boolean;
  55965. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55966. EXPOSURE: boolean;
  55967. MULTIVIEW: boolean;
  55968. USEPHYSICALLIGHTFALLOFF: boolean;
  55969. USEGLTFLIGHTFALLOFF: boolean;
  55970. TWOSIDEDLIGHTING: boolean;
  55971. SHADOWFLOAT: boolean;
  55972. CLIPPLANE: boolean;
  55973. CLIPPLANE2: boolean;
  55974. CLIPPLANE3: boolean;
  55975. CLIPPLANE4: boolean;
  55976. CLIPPLANE5: boolean;
  55977. CLIPPLANE6: boolean;
  55978. POINTSIZE: boolean;
  55979. FOG: boolean;
  55980. LOGARITHMICDEPTH: boolean;
  55981. FORCENORMALFORWARD: boolean;
  55982. SPECULARAA: boolean;
  55983. CLEARCOAT: boolean;
  55984. CLEARCOAT_DEFAULTIOR: boolean;
  55985. CLEARCOAT_TEXTURE: boolean;
  55986. CLEARCOAT_TEXTUREDIRECTUV: number;
  55987. CLEARCOAT_BUMP: boolean;
  55988. CLEARCOAT_BUMPDIRECTUV: number;
  55989. CLEARCOAT_TINT: boolean;
  55990. CLEARCOAT_TINT_TEXTURE: boolean;
  55991. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55992. ANISOTROPIC: boolean;
  55993. ANISOTROPIC_TEXTURE: boolean;
  55994. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55995. BRDF_V_HEIGHT_CORRELATED: boolean;
  55996. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55997. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55998. SHEEN: boolean;
  55999. SHEEN_TEXTURE: boolean;
  56000. SHEEN_TEXTUREDIRECTUV: number;
  56001. SHEEN_LINKWITHALBEDO: boolean;
  56002. SHEEN_ROUGHNESS: boolean;
  56003. SHEEN_ALBEDOSCALING: boolean;
  56004. SUBSURFACE: boolean;
  56005. SS_REFRACTION: boolean;
  56006. SS_TRANSLUCENCY: boolean;
  56007. SS_SCATTERING: boolean;
  56008. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56009. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56010. SS_REFRACTIONMAP_3D: boolean;
  56011. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56012. SS_LODINREFRACTIONALPHA: boolean;
  56013. SS_GAMMAREFRACTION: boolean;
  56014. SS_RGBDREFRACTION: boolean;
  56015. SS_LINEARSPECULARREFRACTION: boolean;
  56016. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56017. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56018. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56019. UNLIT: boolean;
  56020. DEBUGMODE: number;
  56021. /**
  56022. * Initializes the PBR Material defines.
  56023. */
  56024. constructor();
  56025. /**
  56026. * Resets the PBR Material defines.
  56027. */
  56028. reset(): void;
  56029. }
  56030. /**
  56031. * The Physically based material base class of BJS.
  56032. *
  56033. * This offers the main features of a standard PBR material.
  56034. * For more information, please refer to the documentation :
  56035. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56036. */
  56037. export abstract class PBRBaseMaterial extends PushMaterial {
  56038. /**
  56039. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56040. */
  56041. static readonly PBRMATERIAL_OPAQUE: number;
  56042. /**
  56043. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56044. */
  56045. static readonly PBRMATERIAL_ALPHATEST: number;
  56046. /**
  56047. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56048. */
  56049. static readonly PBRMATERIAL_ALPHABLEND: number;
  56050. /**
  56051. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56052. * They are also discarded below the alpha cutoff threshold to improve performances.
  56053. */
  56054. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56055. /**
  56056. * Defines the default value of how much AO map is occluding the analytical lights
  56057. * (point spot...).
  56058. */
  56059. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56060. /**
  56061. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56062. */
  56063. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56064. /**
  56065. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56066. * to enhance interoperability with other engines.
  56067. */
  56068. static readonly LIGHTFALLOFF_GLTF: number;
  56069. /**
  56070. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56071. * to enhance interoperability with other materials.
  56072. */
  56073. static readonly LIGHTFALLOFF_STANDARD: number;
  56074. /**
  56075. * Intensity of the direct lights e.g. the four lights available in your scene.
  56076. * This impacts both the direct diffuse and specular highlights.
  56077. */
  56078. protected _directIntensity: number;
  56079. /**
  56080. * Intensity of the emissive part of the material.
  56081. * This helps controlling the emissive effect without modifying the emissive color.
  56082. */
  56083. protected _emissiveIntensity: number;
  56084. /**
  56085. * Intensity of the environment e.g. how much the environment will light the object
  56086. * either through harmonics for rough material or through the refelction for shiny ones.
  56087. */
  56088. protected _environmentIntensity: number;
  56089. /**
  56090. * This is a special control allowing the reduction of the specular highlights coming from the
  56091. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56092. */
  56093. protected _specularIntensity: number;
  56094. /**
  56095. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56096. */
  56097. private _lightingInfos;
  56098. /**
  56099. * Debug Control allowing disabling the bump map on this material.
  56100. */
  56101. protected _disableBumpMap: boolean;
  56102. /**
  56103. * AKA Diffuse Texture in standard nomenclature.
  56104. */
  56105. protected _albedoTexture: Nullable<BaseTexture>;
  56106. /**
  56107. * AKA Occlusion Texture in other nomenclature.
  56108. */
  56109. protected _ambientTexture: Nullable<BaseTexture>;
  56110. /**
  56111. * AKA Occlusion Texture Intensity in other nomenclature.
  56112. */
  56113. protected _ambientTextureStrength: number;
  56114. /**
  56115. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56116. * 1 means it completely occludes it
  56117. * 0 mean it has no impact
  56118. */
  56119. protected _ambientTextureImpactOnAnalyticalLights: number;
  56120. /**
  56121. * Stores the alpha values in a texture.
  56122. */
  56123. protected _opacityTexture: Nullable<BaseTexture>;
  56124. /**
  56125. * Stores the reflection values in a texture.
  56126. */
  56127. protected _reflectionTexture: Nullable<BaseTexture>;
  56128. /**
  56129. * Stores the emissive values in a texture.
  56130. */
  56131. protected _emissiveTexture: Nullable<BaseTexture>;
  56132. /**
  56133. * AKA Specular texture in other nomenclature.
  56134. */
  56135. protected _reflectivityTexture: Nullable<BaseTexture>;
  56136. /**
  56137. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56138. */
  56139. protected _metallicTexture: Nullable<BaseTexture>;
  56140. /**
  56141. * Specifies the metallic scalar of the metallic/roughness workflow.
  56142. * Can also be used to scale the metalness values of the metallic texture.
  56143. */
  56144. protected _metallic: Nullable<number>;
  56145. /**
  56146. * Specifies the roughness scalar of the metallic/roughness workflow.
  56147. * Can also be used to scale the roughness values of the metallic texture.
  56148. */
  56149. protected _roughness: Nullable<number>;
  56150. /**
  56151. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56152. * By default the indexOfrefraction is used to compute F0;
  56153. *
  56154. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56155. *
  56156. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56157. * F90 = metallicReflectanceColor;
  56158. */
  56159. protected _metallicF0Factor: number;
  56160. /**
  56161. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56162. * By default the F90 is always 1;
  56163. *
  56164. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56165. *
  56166. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56167. * F90 = metallicReflectanceColor;
  56168. */
  56169. protected _metallicReflectanceColor: Color3;
  56170. /**
  56171. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56172. * This is multiply against the scalar values defined in the material.
  56173. */
  56174. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56175. /**
  56176. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56177. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56178. */
  56179. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56180. /**
  56181. * Stores surface normal data used to displace a mesh in a texture.
  56182. */
  56183. protected _bumpTexture: Nullable<BaseTexture>;
  56184. /**
  56185. * Stores the pre-calculated light information of a mesh in a texture.
  56186. */
  56187. protected _lightmapTexture: Nullable<BaseTexture>;
  56188. /**
  56189. * The color of a material in ambient lighting.
  56190. */
  56191. protected _ambientColor: Color3;
  56192. /**
  56193. * AKA Diffuse Color in other nomenclature.
  56194. */
  56195. protected _albedoColor: Color3;
  56196. /**
  56197. * AKA Specular Color in other nomenclature.
  56198. */
  56199. protected _reflectivityColor: Color3;
  56200. /**
  56201. * The color applied when light is reflected from a material.
  56202. */
  56203. protected _reflectionColor: Color3;
  56204. /**
  56205. * The color applied when light is emitted from a material.
  56206. */
  56207. protected _emissiveColor: Color3;
  56208. /**
  56209. * AKA Glossiness in other nomenclature.
  56210. */
  56211. protected _microSurface: number;
  56212. /**
  56213. * Specifies that the material will use the light map as a show map.
  56214. */
  56215. protected _useLightmapAsShadowmap: boolean;
  56216. /**
  56217. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56218. * makes the reflect vector face the model (under horizon).
  56219. */
  56220. protected _useHorizonOcclusion: boolean;
  56221. /**
  56222. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56223. * too much the area relying on ambient texture to define their ambient occlusion.
  56224. */
  56225. protected _useRadianceOcclusion: boolean;
  56226. /**
  56227. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56228. */
  56229. protected _useAlphaFromAlbedoTexture: boolean;
  56230. /**
  56231. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56232. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56233. */
  56234. protected _useSpecularOverAlpha: boolean;
  56235. /**
  56236. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56237. */
  56238. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56239. /**
  56240. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56241. */
  56242. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56243. /**
  56244. * Specifies if the metallic texture contains the roughness information in its green channel.
  56245. */
  56246. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56247. /**
  56248. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56249. */
  56250. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56251. /**
  56252. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56253. */
  56254. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56255. /**
  56256. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56257. */
  56258. protected _useAmbientInGrayScale: boolean;
  56259. /**
  56260. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56261. * The material will try to infer what glossiness each pixel should be.
  56262. */
  56263. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56264. /**
  56265. * Defines the falloff type used in this material.
  56266. * It by default is Physical.
  56267. */
  56268. protected _lightFalloff: number;
  56269. /**
  56270. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56271. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56272. */
  56273. protected _useRadianceOverAlpha: boolean;
  56274. /**
  56275. * Allows using an object space normal map (instead of tangent space).
  56276. */
  56277. protected _useObjectSpaceNormalMap: boolean;
  56278. /**
  56279. * Allows using the bump map in parallax mode.
  56280. */
  56281. protected _useParallax: boolean;
  56282. /**
  56283. * Allows using the bump map in parallax occlusion mode.
  56284. */
  56285. protected _useParallaxOcclusion: boolean;
  56286. /**
  56287. * Controls the scale bias of the parallax mode.
  56288. */
  56289. protected _parallaxScaleBias: number;
  56290. /**
  56291. * If sets to true, disables all the lights affecting the material.
  56292. */
  56293. protected _disableLighting: boolean;
  56294. /**
  56295. * Number of Simultaneous lights allowed on the material.
  56296. */
  56297. protected _maxSimultaneousLights: number;
  56298. /**
  56299. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56300. */
  56301. protected _invertNormalMapX: boolean;
  56302. /**
  56303. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56304. */
  56305. protected _invertNormalMapY: boolean;
  56306. /**
  56307. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56308. */
  56309. protected _twoSidedLighting: boolean;
  56310. /**
  56311. * Defines the alpha limits in alpha test mode.
  56312. */
  56313. protected _alphaCutOff: number;
  56314. /**
  56315. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56316. */
  56317. protected _forceAlphaTest: boolean;
  56318. /**
  56319. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56320. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56321. */
  56322. protected _useAlphaFresnel: boolean;
  56323. /**
  56324. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56325. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56326. */
  56327. protected _useLinearAlphaFresnel: boolean;
  56328. /**
  56329. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56330. * from cos thetav and roughness:
  56331. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56332. */
  56333. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56334. /**
  56335. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56336. */
  56337. protected _forceIrradianceInFragment: boolean;
  56338. private _realTimeFiltering;
  56339. /**
  56340. * Enables realtime filtering on the texture.
  56341. */
  56342. get realTimeFiltering(): boolean;
  56343. set realTimeFiltering(b: boolean);
  56344. private _realTimeFilteringQuality;
  56345. /**
  56346. * Quality switch for realtime filtering
  56347. */
  56348. get realTimeFilteringQuality(): number;
  56349. set realTimeFilteringQuality(n: number);
  56350. /**
  56351. * Can this material render to several textures at once
  56352. */
  56353. get canRenderToMRT(): boolean;
  56354. /**
  56355. * Force normal to face away from face.
  56356. */
  56357. protected _forceNormalForward: boolean;
  56358. /**
  56359. * Enables specular anti aliasing in the PBR shader.
  56360. * It will both interacts on the Geometry for analytical and IBL lighting.
  56361. * It also prefilter the roughness map based on the bump values.
  56362. */
  56363. protected _enableSpecularAntiAliasing: boolean;
  56364. /**
  56365. * Default configuration related to image processing available in the PBR Material.
  56366. */
  56367. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56368. /**
  56369. * Keep track of the image processing observer to allow dispose and replace.
  56370. */
  56371. private _imageProcessingObserver;
  56372. /**
  56373. * Attaches a new image processing configuration to the PBR Material.
  56374. * @param configuration
  56375. */
  56376. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56377. /**
  56378. * Stores the available render targets.
  56379. */
  56380. private _renderTargets;
  56381. /**
  56382. * Sets the global ambient color for the material used in lighting calculations.
  56383. */
  56384. private _globalAmbientColor;
  56385. /**
  56386. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56387. */
  56388. private _useLogarithmicDepth;
  56389. /**
  56390. * If set to true, no lighting calculations will be applied.
  56391. */
  56392. private _unlit;
  56393. private _debugMode;
  56394. /**
  56395. * @hidden
  56396. * This is reserved for the inspector.
  56397. * Defines the material debug mode.
  56398. * It helps seeing only some components of the material while troubleshooting.
  56399. */
  56400. debugMode: number;
  56401. /**
  56402. * @hidden
  56403. * This is reserved for the inspector.
  56404. * Specify from where on screen the debug mode should start.
  56405. * The value goes from -1 (full screen) to 1 (not visible)
  56406. * It helps with side by side comparison against the final render
  56407. * This defaults to -1
  56408. */
  56409. private debugLimit;
  56410. /**
  56411. * @hidden
  56412. * This is reserved for the inspector.
  56413. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56414. * You can use the factor to better multiply the final value.
  56415. */
  56416. private debugFactor;
  56417. /**
  56418. * Defines the clear coat layer parameters for the material.
  56419. */
  56420. readonly clearCoat: PBRClearCoatConfiguration;
  56421. /**
  56422. * Defines the anisotropic parameters for the material.
  56423. */
  56424. readonly anisotropy: PBRAnisotropicConfiguration;
  56425. /**
  56426. * Defines the BRDF parameters for the material.
  56427. */
  56428. readonly brdf: PBRBRDFConfiguration;
  56429. /**
  56430. * Defines the Sheen parameters for the material.
  56431. */
  56432. readonly sheen: PBRSheenConfiguration;
  56433. /**
  56434. * Defines the SubSurface parameters for the material.
  56435. */
  56436. readonly subSurface: PBRSubSurfaceConfiguration;
  56437. /**
  56438. * Defines the detail map parameters for the material.
  56439. */
  56440. readonly detailMap: DetailMapConfiguration;
  56441. protected _rebuildInParallel: boolean;
  56442. /**
  56443. * Instantiates a new PBRMaterial instance.
  56444. *
  56445. * @param name The material name
  56446. * @param scene The scene the material will be use in.
  56447. */
  56448. constructor(name: string, scene: Scene);
  56449. /**
  56450. * Gets a boolean indicating that current material needs to register RTT
  56451. */
  56452. get hasRenderTargetTextures(): boolean;
  56453. /**
  56454. * Gets the name of the material class.
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56459. */
  56460. get useLogarithmicDepth(): boolean;
  56461. /**
  56462. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56463. */
  56464. set useLogarithmicDepth(value: boolean);
  56465. /**
  56466. * Returns true if alpha blending should be disabled.
  56467. */
  56468. protected get _disableAlphaBlending(): boolean;
  56469. /**
  56470. * Specifies whether or not this material should be rendered in alpha blend mode.
  56471. */
  56472. needAlphaBlending(): boolean;
  56473. /**
  56474. * Specifies whether or not this material should be rendered in alpha test mode.
  56475. */
  56476. needAlphaTesting(): boolean;
  56477. /**
  56478. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56479. */
  56480. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56481. /**
  56482. * Gets the texture used for the alpha test.
  56483. */
  56484. getAlphaTestTexture(): Nullable<BaseTexture>;
  56485. /**
  56486. * Specifies that the submesh is ready to be used.
  56487. * @param mesh - BJS mesh.
  56488. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56489. * @param useInstances - Specifies that instances should be used.
  56490. * @returns - boolean indicating that the submesh is ready or not.
  56491. */
  56492. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56493. /**
  56494. * Specifies if the material uses metallic roughness workflow.
  56495. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56496. */
  56497. isMetallicWorkflow(): boolean;
  56498. private _prepareEffect;
  56499. private _prepareDefines;
  56500. /**
  56501. * Force shader compilation
  56502. */
  56503. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56504. /**
  56505. * Initializes the uniform buffer layout for the shader.
  56506. */
  56507. buildUniformLayout(): void;
  56508. /**
  56509. * Unbinds the material from the mesh
  56510. */
  56511. unbind(): void;
  56512. /**
  56513. * Binds the submesh data.
  56514. * @param world - The world matrix.
  56515. * @param mesh - The BJS mesh.
  56516. * @param subMesh - A submesh of the BJS mesh.
  56517. */
  56518. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56519. /**
  56520. * Returns the animatable textures.
  56521. * @returns - Array of animatable textures.
  56522. */
  56523. getAnimatables(): IAnimatable[];
  56524. /**
  56525. * Returns the texture used for reflections.
  56526. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56527. */
  56528. private _getReflectionTexture;
  56529. /**
  56530. * Returns an array of the actively used textures.
  56531. * @returns - Array of BaseTextures
  56532. */
  56533. getActiveTextures(): BaseTexture[];
  56534. /**
  56535. * Checks to see if a texture is used in the material.
  56536. * @param texture - Base texture to use.
  56537. * @returns - Boolean specifying if a texture is used in the material.
  56538. */
  56539. hasTexture(texture: BaseTexture): boolean;
  56540. /**
  56541. * Sets the required values to the prepass renderer.
  56542. * @param prePassRenderer defines the prepass renderer to setup
  56543. */
  56544. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56545. /**
  56546. * Disposes the resources of the material.
  56547. * @param forceDisposeEffect - Forces the disposal of effects.
  56548. * @param forceDisposeTextures - Forces the disposal of all textures.
  56549. */
  56550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56551. }
  56552. }
  56553. declare module BABYLON {
  56554. /**
  56555. * The Physically based material of BJS.
  56556. *
  56557. * This offers the main features of a standard PBR material.
  56558. * For more information, please refer to the documentation :
  56559. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56560. */
  56561. export class PBRMaterial extends PBRBaseMaterial {
  56562. /**
  56563. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56564. */
  56565. static readonly PBRMATERIAL_OPAQUE: number;
  56566. /**
  56567. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56568. */
  56569. static readonly PBRMATERIAL_ALPHATEST: number;
  56570. /**
  56571. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56572. */
  56573. static readonly PBRMATERIAL_ALPHABLEND: number;
  56574. /**
  56575. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56576. * They are also discarded below the alpha cutoff threshold to improve performances.
  56577. */
  56578. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56579. /**
  56580. * Defines the default value of how much AO map is occluding the analytical lights
  56581. * (point spot...).
  56582. */
  56583. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56584. /**
  56585. * Intensity of the direct lights e.g. the four lights available in your scene.
  56586. * This impacts both the direct diffuse and specular highlights.
  56587. */
  56588. directIntensity: number;
  56589. /**
  56590. * Intensity of the emissive part of the material.
  56591. * This helps controlling the emissive effect without modifying the emissive color.
  56592. */
  56593. emissiveIntensity: number;
  56594. /**
  56595. * Intensity of the environment e.g. how much the environment will light the object
  56596. * either through harmonics for rough material or through the refelction for shiny ones.
  56597. */
  56598. environmentIntensity: number;
  56599. /**
  56600. * This is a special control allowing the reduction of the specular highlights coming from the
  56601. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56602. */
  56603. specularIntensity: number;
  56604. /**
  56605. * Debug Control allowing disabling the bump map on this material.
  56606. */
  56607. disableBumpMap: boolean;
  56608. /**
  56609. * AKA Diffuse Texture in standard nomenclature.
  56610. */
  56611. albedoTexture: BaseTexture;
  56612. /**
  56613. * AKA Occlusion Texture in other nomenclature.
  56614. */
  56615. ambientTexture: BaseTexture;
  56616. /**
  56617. * AKA Occlusion Texture Intensity in other nomenclature.
  56618. */
  56619. ambientTextureStrength: number;
  56620. /**
  56621. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56622. * 1 means it completely occludes it
  56623. * 0 mean it has no impact
  56624. */
  56625. ambientTextureImpactOnAnalyticalLights: number;
  56626. /**
  56627. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56628. */
  56629. opacityTexture: BaseTexture;
  56630. /**
  56631. * Stores the reflection values in a texture.
  56632. */
  56633. reflectionTexture: Nullable<BaseTexture>;
  56634. /**
  56635. * Stores the emissive values in a texture.
  56636. */
  56637. emissiveTexture: BaseTexture;
  56638. /**
  56639. * AKA Specular texture in other nomenclature.
  56640. */
  56641. reflectivityTexture: BaseTexture;
  56642. /**
  56643. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56644. */
  56645. metallicTexture: BaseTexture;
  56646. /**
  56647. * Specifies the metallic scalar of the metallic/roughness workflow.
  56648. * Can also be used to scale the metalness values of the metallic texture.
  56649. */
  56650. metallic: Nullable<number>;
  56651. /**
  56652. * Specifies the roughness scalar of the metallic/roughness workflow.
  56653. * Can also be used to scale the roughness values of the metallic texture.
  56654. */
  56655. roughness: Nullable<number>;
  56656. /**
  56657. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56658. * By default the indexOfrefraction is used to compute F0;
  56659. *
  56660. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56661. *
  56662. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56663. * F90 = metallicReflectanceColor;
  56664. */
  56665. metallicF0Factor: number;
  56666. /**
  56667. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56668. * By default the F90 is always 1;
  56669. *
  56670. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56671. *
  56672. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56673. * F90 = metallicReflectanceColor;
  56674. */
  56675. metallicReflectanceColor: Color3;
  56676. /**
  56677. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56678. * This is multiply against the scalar values defined in the material.
  56679. */
  56680. metallicReflectanceTexture: Nullable<BaseTexture>;
  56681. /**
  56682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56684. */
  56685. microSurfaceTexture: BaseTexture;
  56686. /**
  56687. * Stores surface normal data used to displace a mesh in a texture.
  56688. */
  56689. bumpTexture: BaseTexture;
  56690. /**
  56691. * Stores the pre-calculated light information of a mesh in a texture.
  56692. */
  56693. lightmapTexture: BaseTexture;
  56694. /**
  56695. * Stores the refracted light information in a texture.
  56696. */
  56697. get refractionTexture(): Nullable<BaseTexture>;
  56698. set refractionTexture(value: Nullable<BaseTexture>);
  56699. /**
  56700. * The color of a material in ambient lighting.
  56701. */
  56702. ambientColor: Color3;
  56703. /**
  56704. * AKA Diffuse Color in other nomenclature.
  56705. */
  56706. albedoColor: Color3;
  56707. /**
  56708. * AKA Specular Color in other nomenclature.
  56709. */
  56710. reflectivityColor: Color3;
  56711. /**
  56712. * The color reflected from the material.
  56713. */
  56714. reflectionColor: Color3;
  56715. /**
  56716. * The color emitted from the material.
  56717. */
  56718. emissiveColor: Color3;
  56719. /**
  56720. * AKA Glossiness in other nomenclature.
  56721. */
  56722. microSurface: number;
  56723. /**
  56724. * Index of refraction of the material base layer.
  56725. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56726. *
  56727. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56728. *
  56729. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56730. */
  56731. get indexOfRefraction(): number;
  56732. set indexOfRefraction(value: number);
  56733. /**
  56734. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56735. */
  56736. get invertRefractionY(): boolean;
  56737. set invertRefractionY(value: boolean);
  56738. /**
  56739. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56740. * Materials half opaque for instance using refraction could benefit from this control.
  56741. */
  56742. get linkRefractionWithTransparency(): boolean;
  56743. set linkRefractionWithTransparency(value: boolean);
  56744. /**
  56745. * If true, the light map contains occlusion information instead of lighting info.
  56746. */
  56747. useLightmapAsShadowmap: boolean;
  56748. /**
  56749. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56750. */
  56751. useAlphaFromAlbedoTexture: boolean;
  56752. /**
  56753. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56754. */
  56755. forceAlphaTest: boolean;
  56756. /**
  56757. * Defines the alpha limits in alpha test mode.
  56758. */
  56759. alphaCutOff: number;
  56760. /**
  56761. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56762. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56763. */
  56764. useSpecularOverAlpha: boolean;
  56765. /**
  56766. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56767. */
  56768. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56769. /**
  56770. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56771. */
  56772. useRoughnessFromMetallicTextureAlpha: boolean;
  56773. /**
  56774. * Specifies if the metallic texture contains the roughness information in its green channel.
  56775. */
  56776. useRoughnessFromMetallicTextureGreen: boolean;
  56777. /**
  56778. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56779. */
  56780. useMetallnessFromMetallicTextureBlue: boolean;
  56781. /**
  56782. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56783. */
  56784. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56785. /**
  56786. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56787. */
  56788. useAmbientInGrayScale: boolean;
  56789. /**
  56790. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56791. * The material will try to infer what glossiness each pixel should be.
  56792. */
  56793. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56794. /**
  56795. * BJS is using an harcoded light falloff based on a manually sets up range.
  56796. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56797. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56798. */
  56799. get usePhysicalLightFalloff(): boolean;
  56800. /**
  56801. * BJS is using an harcoded light falloff based on a manually sets up range.
  56802. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56803. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56804. */
  56805. set usePhysicalLightFalloff(value: boolean);
  56806. /**
  56807. * In order to support the falloff compatibility with gltf, a special mode has been added
  56808. * to reproduce the gltf light falloff.
  56809. */
  56810. get useGLTFLightFalloff(): boolean;
  56811. /**
  56812. * In order to support the falloff compatibility with gltf, a special mode has been added
  56813. * to reproduce the gltf light falloff.
  56814. */
  56815. set useGLTFLightFalloff(value: boolean);
  56816. /**
  56817. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56818. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56819. */
  56820. useRadianceOverAlpha: boolean;
  56821. /**
  56822. * Allows using an object space normal map (instead of tangent space).
  56823. */
  56824. useObjectSpaceNormalMap: boolean;
  56825. /**
  56826. * Allows using the bump map in parallax mode.
  56827. */
  56828. useParallax: boolean;
  56829. /**
  56830. * Allows using the bump map in parallax occlusion mode.
  56831. */
  56832. useParallaxOcclusion: boolean;
  56833. /**
  56834. * Controls the scale bias of the parallax mode.
  56835. */
  56836. parallaxScaleBias: number;
  56837. /**
  56838. * If sets to true, disables all the lights affecting the material.
  56839. */
  56840. disableLighting: boolean;
  56841. /**
  56842. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56843. */
  56844. forceIrradianceInFragment: boolean;
  56845. /**
  56846. * Number of Simultaneous lights allowed on the material.
  56847. */
  56848. maxSimultaneousLights: number;
  56849. /**
  56850. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56851. */
  56852. invertNormalMapX: boolean;
  56853. /**
  56854. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56855. */
  56856. invertNormalMapY: boolean;
  56857. /**
  56858. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56859. */
  56860. twoSidedLighting: boolean;
  56861. /**
  56862. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56863. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56864. */
  56865. useAlphaFresnel: boolean;
  56866. /**
  56867. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56868. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56869. */
  56870. useLinearAlphaFresnel: boolean;
  56871. /**
  56872. * Let user defines the brdf lookup texture used for IBL.
  56873. * A default 8bit version is embedded but you could point at :
  56874. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56875. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56876. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56877. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56878. */
  56879. environmentBRDFTexture: Nullable<BaseTexture>;
  56880. /**
  56881. * Force normal to face away from face.
  56882. */
  56883. forceNormalForward: boolean;
  56884. /**
  56885. * Enables specular anti aliasing in the PBR shader.
  56886. * It will both interacts on the Geometry for analytical and IBL lighting.
  56887. * It also prefilter the roughness map based on the bump values.
  56888. */
  56889. enableSpecularAntiAliasing: boolean;
  56890. /**
  56891. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56892. * makes the reflect vector face the model (under horizon).
  56893. */
  56894. useHorizonOcclusion: boolean;
  56895. /**
  56896. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56897. * too much the area relying on ambient texture to define their ambient occlusion.
  56898. */
  56899. useRadianceOcclusion: boolean;
  56900. /**
  56901. * If set to true, no lighting calculations will be applied.
  56902. */
  56903. unlit: boolean;
  56904. /**
  56905. * Gets the image processing configuration used either in this material.
  56906. */
  56907. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56908. /**
  56909. * Sets the Default image processing configuration used either in the this material.
  56910. *
  56911. * If sets to null, the scene one is in use.
  56912. */
  56913. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56914. /**
  56915. * Gets wether the color curves effect is enabled.
  56916. */
  56917. get cameraColorCurvesEnabled(): boolean;
  56918. /**
  56919. * Sets wether the color curves effect is enabled.
  56920. */
  56921. set cameraColorCurvesEnabled(value: boolean);
  56922. /**
  56923. * Gets wether the color grading effect is enabled.
  56924. */
  56925. get cameraColorGradingEnabled(): boolean;
  56926. /**
  56927. * Gets wether the color grading effect is enabled.
  56928. */
  56929. set cameraColorGradingEnabled(value: boolean);
  56930. /**
  56931. * Gets wether tonemapping is enabled or not.
  56932. */
  56933. get cameraToneMappingEnabled(): boolean;
  56934. /**
  56935. * Sets wether tonemapping is enabled or not
  56936. */
  56937. set cameraToneMappingEnabled(value: boolean);
  56938. /**
  56939. * The camera exposure used on this material.
  56940. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56941. * This corresponds to a photographic exposure.
  56942. */
  56943. get cameraExposure(): number;
  56944. /**
  56945. * The camera exposure used on this material.
  56946. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56947. * This corresponds to a photographic exposure.
  56948. */
  56949. set cameraExposure(value: number);
  56950. /**
  56951. * Gets The camera contrast used on this material.
  56952. */
  56953. get cameraContrast(): number;
  56954. /**
  56955. * Sets The camera contrast used on this material.
  56956. */
  56957. set cameraContrast(value: number);
  56958. /**
  56959. * Gets the Color Grading 2D Lookup Texture.
  56960. */
  56961. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56962. /**
  56963. * Sets the Color Grading 2D Lookup Texture.
  56964. */
  56965. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56966. /**
  56967. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56968. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56969. * 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;
  56970. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56971. */
  56972. get cameraColorCurves(): Nullable<ColorCurves>;
  56973. /**
  56974. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56975. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56976. * 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;
  56977. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56978. */
  56979. set cameraColorCurves(value: Nullable<ColorCurves>);
  56980. /**
  56981. * Instantiates a new PBRMaterial instance.
  56982. *
  56983. * @param name The material name
  56984. * @param scene The scene the material will be use in.
  56985. */
  56986. constructor(name: string, scene: Scene);
  56987. /**
  56988. * Returns the name of this material class.
  56989. */
  56990. getClassName(): string;
  56991. /**
  56992. * Makes a duplicate of the current material.
  56993. * @param name - name to use for the new material.
  56994. */
  56995. clone(name: string): PBRMaterial;
  56996. /**
  56997. * Serializes this PBR Material.
  56998. * @returns - An object with the serialized material.
  56999. */
  57000. serialize(): any;
  57001. /**
  57002. * Parses a PBR Material from a serialized object.
  57003. * @param source - Serialized object.
  57004. * @param scene - BJS scene instance.
  57005. * @param rootUrl - url for the scene object
  57006. * @returns - PBRMaterial
  57007. */
  57008. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57009. }
  57010. }
  57011. declare module BABYLON {
  57012. /**
  57013. * Direct draw surface info
  57014. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57015. */
  57016. export interface DDSInfo {
  57017. /**
  57018. * Width of the texture
  57019. */
  57020. width: number;
  57021. /**
  57022. * Width of the texture
  57023. */
  57024. height: number;
  57025. /**
  57026. * Number of Mipmaps for the texture
  57027. * @see https://en.wikipedia.org/wiki/Mipmap
  57028. */
  57029. mipmapCount: number;
  57030. /**
  57031. * If the textures format is a known fourCC format
  57032. * @see https://www.fourcc.org/
  57033. */
  57034. isFourCC: boolean;
  57035. /**
  57036. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57037. */
  57038. isRGB: boolean;
  57039. /**
  57040. * If the texture is a lumincance format
  57041. */
  57042. isLuminance: boolean;
  57043. /**
  57044. * If this is a cube texture
  57045. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57046. */
  57047. isCube: boolean;
  57048. /**
  57049. * If the texture is a compressed format eg. FOURCC_DXT1
  57050. */
  57051. isCompressed: boolean;
  57052. /**
  57053. * The dxgiFormat of the texture
  57054. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57055. */
  57056. dxgiFormat: number;
  57057. /**
  57058. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57059. */
  57060. textureType: number;
  57061. /**
  57062. * Sphericle polynomial created for the dds texture
  57063. */
  57064. sphericalPolynomial?: SphericalPolynomial;
  57065. }
  57066. /**
  57067. * Class used to provide DDS decompression tools
  57068. */
  57069. export class DDSTools {
  57070. /**
  57071. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57072. */
  57073. static StoreLODInAlphaChannel: boolean;
  57074. /**
  57075. * Gets DDS information from an array buffer
  57076. * @param data defines the array buffer view to read data from
  57077. * @returns the DDS information
  57078. */
  57079. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57080. private static _FloatView;
  57081. private static _Int32View;
  57082. private static _ToHalfFloat;
  57083. private static _FromHalfFloat;
  57084. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57085. private static _GetHalfFloatRGBAArrayBuffer;
  57086. private static _GetFloatRGBAArrayBuffer;
  57087. private static _GetFloatAsUIntRGBAArrayBuffer;
  57088. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57089. private static _GetRGBAArrayBuffer;
  57090. private static _ExtractLongWordOrder;
  57091. private static _GetRGBArrayBuffer;
  57092. private static _GetLuminanceArrayBuffer;
  57093. /**
  57094. * Uploads DDS Levels to a Babylon Texture
  57095. * @hidden
  57096. */
  57097. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57098. }
  57099. interface ThinEngine {
  57100. /**
  57101. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57102. * @param rootUrl defines the url where the file to load is located
  57103. * @param scene defines the current scene
  57104. * @param lodScale defines scale to apply to the mip map selection
  57105. * @param lodOffset defines offset to apply to the mip map selection
  57106. * @param onLoad defines an optional callback raised when the texture is loaded
  57107. * @param onError defines an optional callback raised if there is an issue to load the texture
  57108. * @param format defines the format of the data
  57109. * @param forcedExtension defines the extension to use to pick the right loader
  57110. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57111. * @returns the cube texture as an InternalTexture
  57112. */
  57113. 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;
  57114. }
  57115. }
  57116. declare module BABYLON {
  57117. /**
  57118. * Implementation of the DDS Texture Loader.
  57119. * @hidden
  57120. */
  57121. export class _DDSTextureLoader implements IInternalTextureLoader {
  57122. /**
  57123. * Defines wether the loader supports cascade loading the different faces.
  57124. */
  57125. readonly supportCascades: boolean;
  57126. /**
  57127. * This returns if the loader support the current file information.
  57128. * @param extension defines the file extension of the file being loaded
  57129. * @returns true if the loader can load the specified file
  57130. */
  57131. canLoad(extension: string): boolean;
  57132. /**
  57133. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57134. * @param data contains the texture data
  57135. * @param texture defines the BabylonJS internal texture
  57136. * @param createPolynomials will be true if polynomials have been requested
  57137. * @param onLoad defines the callback to trigger once the texture is ready
  57138. * @param onError defines the callback to trigger in case of error
  57139. */
  57140. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57141. /**
  57142. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57143. * @param data contains the texture data
  57144. * @param texture defines the BabylonJS internal texture
  57145. * @param callback defines the method to call once ready to upload
  57146. */
  57147. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57148. }
  57149. }
  57150. declare module BABYLON {
  57151. /**
  57152. * Implementation of the ENV Texture Loader.
  57153. * @hidden
  57154. */
  57155. export class _ENVTextureLoader implements IInternalTextureLoader {
  57156. /**
  57157. * Defines wether the loader supports cascade loading the different faces.
  57158. */
  57159. readonly supportCascades: boolean;
  57160. /**
  57161. * This returns if the loader support the current file information.
  57162. * @param extension defines the file extension of the file being loaded
  57163. * @returns true if the loader can load the specified file
  57164. */
  57165. canLoad(extension: string): boolean;
  57166. /**
  57167. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57168. * @param data contains the texture data
  57169. * @param texture defines the BabylonJS internal texture
  57170. * @param createPolynomials will be true if polynomials have been requested
  57171. * @param onLoad defines the callback to trigger once the texture is ready
  57172. * @param onError defines the callback to trigger in case of error
  57173. */
  57174. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57175. /**
  57176. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57177. * @param data contains the texture data
  57178. * @param texture defines the BabylonJS internal texture
  57179. * @param callback defines the method to call once ready to upload
  57180. */
  57181. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57182. }
  57183. }
  57184. declare module BABYLON {
  57185. /**
  57186. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57187. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57188. */
  57189. export class KhronosTextureContainer {
  57190. /** contents of the KTX container file */
  57191. data: ArrayBufferView;
  57192. private static HEADER_LEN;
  57193. private static COMPRESSED_2D;
  57194. private static COMPRESSED_3D;
  57195. private static TEX_2D;
  57196. private static TEX_3D;
  57197. /**
  57198. * Gets the openGL type
  57199. */
  57200. glType: number;
  57201. /**
  57202. * Gets the openGL type size
  57203. */
  57204. glTypeSize: number;
  57205. /**
  57206. * Gets the openGL format
  57207. */
  57208. glFormat: number;
  57209. /**
  57210. * Gets the openGL internal format
  57211. */
  57212. glInternalFormat: number;
  57213. /**
  57214. * Gets the base internal format
  57215. */
  57216. glBaseInternalFormat: number;
  57217. /**
  57218. * Gets image width in pixel
  57219. */
  57220. pixelWidth: number;
  57221. /**
  57222. * Gets image height in pixel
  57223. */
  57224. pixelHeight: number;
  57225. /**
  57226. * Gets image depth in pixels
  57227. */
  57228. pixelDepth: number;
  57229. /**
  57230. * Gets the number of array elements
  57231. */
  57232. numberOfArrayElements: number;
  57233. /**
  57234. * Gets the number of faces
  57235. */
  57236. numberOfFaces: number;
  57237. /**
  57238. * Gets the number of mipmap levels
  57239. */
  57240. numberOfMipmapLevels: number;
  57241. /**
  57242. * Gets the bytes of key value data
  57243. */
  57244. bytesOfKeyValueData: number;
  57245. /**
  57246. * Gets the load type
  57247. */
  57248. loadType: number;
  57249. /**
  57250. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57251. */
  57252. isInvalid: boolean;
  57253. /**
  57254. * Creates a new KhronosTextureContainer
  57255. * @param data contents of the KTX container file
  57256. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57257. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57258. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57259. */
  57260. constructor(
  57261. /** contents of the KTX container file */
  57262. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57263. /**
  57264. * Uploads KTX content to a Babylon Texture.
  57265. * It is assumed that the texture has already been created & is currently bound
  57266. * @hidden
  57267. */
  57268. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57269. private _upload2DCompressedLevels;
  57270. /**
  57271. * Checks if the given data starts with a KTX file identifier.
  57272. * @param data the data to check
  57273. * @returns true if the data is a KTX file or false otherwise
  57274. */
  57275. static IsValid(data: ArrayBufferView): boolean;
  57276. }
  57277. }
  57278. declare module BABYLON {
  57279. /**
  57280. * Class for loading KTX2 files
  57281. * !!! Experimental Extension Subject to Changes !!!
  57282. * @hidden
  57283. */
  57284. export class KhronosTextureContainer2 {
  57285. private static _ModulePromise;
  57286. private static _TranscodeFormat;
  57287. constructor(engine: ThinEngine);
  57288. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57289. private _determineTranscodeFormat;
  57290. /**
  57291. * Checks if the given data starts with a KTX2 file identifier.
  57292. * @param data the data to check
  57293. * @returns true if the data is a KTX2 file or false otherwise
  57294. */
  57295. static IsValid(data: ArrayBufferView): boolean;
  57296. }
  57297. }
  57298. declare module BABYLON {
  57299. /**
  57300. * Implementation of the KTX Texture Loader.
  57301. * @hidden
  57302. */
  57303. export class _KTXTextureLoader implements IInternalTextureLoader {
  57304. /**
  57305. * Defines wether the loader supports cascade loading the different faces.
  57306. */
  57307. readonly supportCascades: boolean;
  57308. /**
  57309. * This returns if the loader support the current file information.
  57310. * @param extension defines the file extension of the file being loaded
  57311. * @param mimeType defines the optional mime type of the file being loaded
  57312. * @returns true if the loader can load the specified file
  57313. */
  57314. canLoad(extension: string, mimeType?: string): boolean;
  57315. /**
  57316. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57317. * @param data contains the texture data
  57318. * @param texture defines the BabylonJS internal texture
  57319. * @param createPolynomials will be true if polynomials have been requested
  57320. * @param onLoad defines the callback to trigger once the texture is ready
  57321. * @param onError defines the callback to trigger in case of error
  57322. */
  57323. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57324. /**
  57325. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57326. * @param data contains the texture data
  57327. * @param texture defines the BabylonJS internal texture
  57328. * @param callback defines the method to call once ready to upload
  57329. */
  57330. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57331. }
  57332. }
  57333. declare module BABYLON {
  57334. /** @hidden */
  57335. export var _forceSceneHelpersToBundle: boolean;
  57336. interface Scene {
  57337. /**
  57338. * Creates a default light for the scene.
  57339. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57340. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57341. */
  57342. createDefaultLight(replace?: boolean): void;
  57343. /**
  57344. * Creates a default camera for the scene.
  57345. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57346. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57347. * @param replace has default false, when true replaces the active camera in the scene
  57348. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57349. */
  57350. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57351. /**
  57352. * Creates a default camera and a default light.
  57353. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57354. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57355. * @param replace has the default false, when true replaces the active camera/light in the scene
  57356. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57357. */
  57358. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57359. /**
  57360. * Creates a new sky box
  57361. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57362. * @param environmentTexture defines the texture to use as environment texture
  57363. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57364. * @param scale defines the overall scale of the skybox
  57365. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57366. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57367. * @returns a new mesh holding the sky box
  57368. */
  57369. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57370. /**
  57371. * Creates a new environment
  57372. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57373. * @param options defines the options you can use to configure the environment
  57374. * @returns the new EnvironmentHelper
  57375. */
  57376. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57377. /**
  57378. * Creates a new VREXperienceHelper
  57379. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57380. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57381. * @returns a new VREXperienceHelper
  57382. */
  57383. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57384. /**
  57385. * Creates a new WebXRDefaultExperience
  57386. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57387. * @param options experience options
  57388. * @returns a promise for a new WebXRDefaultExperience
  57389. */
  57390. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57391. }
  57392. }
  57393. declare module BABYLON {
  57394. /**
  57395. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57396. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57397. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57398. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57399. */
  57400. export class VideoDome extends TransformNode {
  57401. /**
  57402. * Define the video source as a Monoscopic panoramic 360 video.
  57403. */
  57404. static readonly MODE_MONOSCOPIC: number;
  57405. /**
  57406. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57407. */
  57408. static readonly MODE_TOPBOTTOM: number;
  57409. /**
  57410. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57411. */
  57412. static readonly MODE_SIDEBYSIDE: number;
  57413. private _halfDome;
  57414. private _useDirectMapping;
  57415. /**
  57416. * The video texture being displayed on the sphere
  57417. */
  57418. protected _videoTexture: VideoTexture;
  57419. /**
  57420. * Gets the video texture being displayed on the sphere
  57421. */
  57422. get videoTexture(): VideoTexture;
  57423. /**
  57424. * The skybox material
  57425. */
  57426. protected _material: BackgroundMaterial;
  57427. /**
  57428. * The surface used for the video dome
  57429. */
  57430. protected _mesh: Mesh;
  57431. /**
  57432. * Gets the mesh used for the video dome.
  57433. */
  57434. get mesh(): Mesh;
  57435. /**
  57436. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57437. */
  57438. private _halfDomeMask;
  57439. /**
  57440. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57441. * Also see the options.resolution property.
  57442. */
  57443. get fovMultiplier(): number;
  57444. set fovMultiplier(value: number);
  57445. private _videoMode;
  57446. /**
  57447. * Gets or set the current video mode for the video. It can be:
  57448. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57449. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57450. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57451. */
  57452. get videoMode(): number;
  57453. set videoMode(value: number);
  57454. /**
  57455. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57456. *
  57457. */
  57458. get halfDome(): boolean;
  57459. /**
  57460. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57461. */
  57462. set halfDome(enabled: boolean);
  57463. /**
  57464. * Oberserver used in Stereoscopic VR Mode.
  57465. */
  57466. private _onBeforeCameraRenderObserver;
  57467. /**
  57468. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57469. * @param name Element's name, child elements will append suffixes for their own names.
  57470. * @param urlsOrVideo defines the url(s) or the video element to use
  57471. * @param options An object containing optional or exposed sub element properties
  57472. */
  57473. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57474. resolution?: number;
  57475. clickToPlay?: boolean;
  57476. autoPlay?: boolean;
  57477. loop?: boolean;
  57478. size?: number;
  57479. poster?: string;
  57480. faceForward?: boolean;
  57481. useDirectMapping?: boolean;
  57482. halfDomeMode?: boolean;
  57483. }, scene: Scene);
  57484. private _changeVideoMode;
  57485. /**
  57486. * Releases resources associated with this node.
  57487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57489. */
  57490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57491. }
  57492. }
  57493. declare module BABYLON {
  57494. /**
  57495. * This class can be used to get instrumentation data from a Babylon engine
  57496. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57497. */
  57498. export class EngineInstrumentation implements IDisposable {
  57499. /**
  57500. * Define the instrumented engine.
  57501. */
  57502. engine: Engine;
  57503. private _captureGPUFrameTime;
  57504. private _gpuFrameTimeToken;
  57505. private _gpuFrameTime;
  57506. private _captureShaderCompilationTime;
  57507. private _shaderCompilationTime;
  57508. private _onBeginFrameObserver;
  57509. private _onEndFrameObserver;
  57510. private _onBeforeShaderCompilationObserver;
  57511. private _onAfterShaderCompilationObserver;
  57512. /**
  57513. * Gets the perf counter used for GPU frame time
  57514. */
  57515. get gpuFrameTimeCounter(): PerfCounter;
  57516. /**
  57517. * Gets the GPU frame time capture status
  57518. */
  57519. get captureGPUFrameTime(): boolean;
  57520. /**
  57521. * Enable or disable the GPU frame time capture
  57522. */
  57523. set captureGPUFrameTime(value: boolean);
  57524. /**
  57525. * Gets the perf counter used for shader compilation time
  57526. */
  57527. get shaderCompilationTimeCounter(): PerfCounter;
  57528. /**
  57529. * Gets the shader compilation time capture status
  57530. */
  57531. get captureShaderCompilationTime(): boolean;
  57532. /**
  57533. * Enable or disable the shader compilation time capture
  57534. */
  57535. set captureShaderCompilationTime(value: boolean);
  57536. /**
  57537. * Instantiates a new engine instrumentation.
  57538. * This class can be used to get instrumentation data from a Babylon engine
  57539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57540. * @param engine Defines the engine to instrument
  57541. */
  57542. constructor(
  57543. /**
  57544. * Define the instrumented engine.
  57545. */
  57546. engine: Engine);
  57547. /**
  57548. * Dispose and release associated resources.
  57549. */
  57550. dispose(): void;
  57551. }
  57552. }
  57553. declare module BABYLON {
  57554. /**
  57555. * This class can be used to get instrumentation data from a Babylon engine
  57556. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57557. */
  57558. export class SceneInstrumentation implements IDisposable {
  57559. /**
  57560. * Defines the scene to instrument
  57561. */
  57562. scene: Scene;
  57563. private _captureActiveMeshesEvaluationTime;
  57564. private _activeMeshesEvaluationTime;
  57565. private _captureRenderTargetsRenderTime;
  57566. private _renderTargetsRenderTime;
  57567. private _captureFrameTime;
  57568. private _frameTime;
  57569. private _captureRenderTime;
  57570. private _renderTime;
  57571. private _captureInterFrameTime;
  57572. private _interFrameTime;
  57573. private _captureParticlesRenderTime;
  57574. private _particlesRenderTime;
  57575. private _captureSpritesRenderTime;
  57576. private _spritesRenderTime;
  57577. private _capturePhysicsTime;
  57578. private _physicsTime;
  57579. private _captureAnimationsTime;
  57580. private _animationsTime;
  57581. private _captureCameraRenderTime;
  57582. private _cameraRenderTime;
  57583. private _onBeforeActiveMeshesEvaluationObserver;
  57584. private _onAfterActiveMeshesEvaluationObserver;
  57585. private _onBeforeRenderTargetsRenderObserver;
  57586. private _onAfterRenderTargetsRenderObserver;
  57587. private _onAfterRenderObserver;
  57588. private _onBeforeDrawPhaseObserver;
  57589. private _onAfterDrawPhaseObserver;
  57590. private _onBeforeAnimationsObserver;
  57591. private _onBeforeParticlesRenderingObserver;
  57592. private _onAfterParticlesRenderingObserver;
  57593. private _onBeforeSpritesRenderingObserver;
  57594. private _onAfterSpritesRenderingObserver;
  57595. private _onBeforePhysicsObserver;
  57596. private _onAfterPhysicsObserver;
  57597. private _onAfterAnimationsObserver;
  57598. private _onBeforeCameraRenderObserver;
  57599. private _onAfterCameraRenderObserver;
  57600. /**
  57601. * Gets the perf counter used for active meshes evaluation time
  57602. */
  57603. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57604. /**
  57605. * Gets the active meshes evaluation time capture status
  57606. */
  57607. get captureActiveMeshesEvaluationTime(): boolean;
  57608. /**
  57609. * Enable or disable the active meshes evaluation time capture
  57610. */
  57611. set captureActiveMeshesEvaluationTime(value: boolean);
  57612. /**
  57613. * Gets the perf counter used for render targets render time
  57614. */
  57615. get renderTargetsRenderTimeCounter(): PerfCounter;
  57616. /**
  57617. * Gets the render targets render time capture status
  57618. */
  57619. get captureRenderTargetsRenderTime(): boolean;
  57620. /**
  57621. * Enable or disable the render targets render time capture
  57622. */
  57623. set captureRenderTargetsRenderTime(value: boolean);
  57624. /**
  57625. * Gets the perf counter used for particles render time
  57626. */
  57627. get particlesRenderTimeCounter(): PerfCounter;
  57628. /**
  57629. * Gets the particles render time capture status
  57630. */
  57631. get captureParticlesRenderTime(): boolean;
  57632. /**
  57633. * Enable or disable the particles render time capture
  57634. */
  57635. set captureParticlesRenderTime(value: boolean);
  57636. /**
  57637. * Gets the perf counter used for sprites render time
  57638. */
  57639. get spritesRenderTimeCounter(): PerfCounter;
  57640. /**
  57641. * Gets the sprites render time capture status
  57642. */
  57643. get captureSpritesRenderTime(): boolean;
  57644. /**
  57645. * Enable or disable the sprites render time capture
  57646. */
  57647. set captureSpritesRenderTime(value: boolean);
  57648. /**
  57649. * Gets the perf counter used for physics time
  57650. */
  57651. get physicsTimeCounter(): PerfCounter;
  57652. /**
  57653. * Gets the physics time capture status
  57654. */
  57655. get capturePhysicsTime(): boolean;
  57656. /**
  57657. * Enable or disable the physics time capture
  57658. */
  57659. set capturePhysicsTime(value: boolean);
  57660. /**
  57661. * Gets the perf counter used for animations time
  57662. */
  57663. get animationsTimeCounter(): PerfCounter;
  57664. /**
  57665. * Gets the animations time capture status
  57666. */
  57667. get captureAnimationsTime(): boolean;
  57668. /**
  57669. * Enable or disable the animations time capture
  57670. */
  57671. set captureAnimationsTime(value: boolean);
  57672. /**
  57673. * Gets the perf counter used for frame time capture
  57674. */
  57675. get frameTimeCounter(): PerfCounter;
  57676. /**
  57677. * Gets the frame time capture status
  57678. */
  57679. get captureFrameTime(): boolean;
  57680. /**
  57681. * Enable or disable the frame time capture
  57682. */
  57683. set captureFrameTime(value: boolean);
  57684. /**
  57685. * Gets the perf counter used for inter-frames time capture
  57686. */
  57687. get interFrameTimeCounter(): PerfCounter;
  57688. /**
  57689. * Gets the inter-frames time capture status
  57690. */
  57691. get captureInterFrameTime(): boolean;
  57692. /**
  57693. * Enable or disable the inter-frames time capture
  57694. */
  57695. set captureInterFrameTime(value: boolean);
  57696. /**
  57697. * Gets the perf counter used for render time capture
  57698. */
  57699. get renderTimeCounter(): PerfCounter;
  57700. /**
  57701. * Gets the render time capture status
  57702. */
  57703. get captureRenderTime(): boolean;
  57704. /**
  57705. * Enable or disable the render time capture
  57706. */
  57707. set captureRenderTime(value: boolean);
  57708. /**
  57709. * Gets the perf counter used for camera render time capture
  57710. */
  57711. get cameraRenderTimeCounter(): PerfCounter;
  57712. /**
  57713. * Gets the camera render time capture status
  57714. */
  57715. get captureCameraRenderTime(): boolean;
  57716. /**
  57717. * Enable or disable the camera render time capture
  57718. */
  57719. set captureCameraRenderTime(value: boolean);
  57720. /**
  57721. * Gets the perf counter used for draw calls
  57722. */
  57723. get drawCallsCounter(): PerfCounter;
  57724. /**
  57725. * Instantiates a new scene instrumentation.
  57726. * This class can be used to get instrumentation data from a Babylon engine
  57727. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57728. * @param scene Defines the scene to instrument
  57729. */
  57730. constructor(
  57731. /**
  57732. * Defines the scene to instrument
  57733. */
  57734. scene: Scene);
  57735. /**
  57736. * Dispose and release associated resources.
  57737. */
  57738. dispose(): void;
  57739. }
  57740. }
  57741. declare module BABYLON {
  57742. /** @hidden */
  57743. export var glowMapGenerationPixelShader: {
  57744. name: string;
  57745. shader: string;
  57746. };
  57747. }
  57748. declare module BABYLON {
  57749. /** @hidden */
  57750. export var glowMapGenerationVertexShader: {
  57751. name: string;
  57752. shader: string;
  57753. };
  57754. }
  57755. declare module BABYLON {
  57756. /**
  57757. * Effect layer options. This helps customizing the behaviour
  57758. * of the effect layer.
  57759. */
  57760. export interface IEffectLayerOptions {
  57761. /**
  57762. * Multiplication factor apply to the canvas size to compute the render target size
  57763. * used to generated the objects (the smaller the faster).
  57764. */
  57765. mainTextureRatio: number;
  57766. /**
  57767. * Enforces a fixed size texture to ensure effect stability across devices.
  57768. */
  57769. mainTextureFixedSize?: number;
  57770. /**
  57771. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57772. */
  57773. alphaBlendingMode: number;
  57774. /**
  57775. * The camera attached to the layer.
  57776. */
  57777. camera: Nullable<Camera>;
  57778. /**
  57779. * The rendering group to draw the layer in.
  57780. */
  57781. renderingGroupId: number;
  57782. }
  57783. /**
  57784. * The effect layer Helps adding post process effect blended with the main pass.
  57785. *
  57786. * This can be for instance use to generate glow or higlight effects on the scene.
  57787. *
  57788. * The effect layer class can not be used directly and is intented to inherited from to be
  57789. * customized per effects.
  57790. */
  57791. export abstract class EffectLayer {
  57792. private _vertexBuffers;
  57793. private _indexBuffer;
  57794. private _cachedDefines;
  57795. private _effectLayerMapGenerationEffect;
  57796. private _effectLayerOptions;
  57797. private _mergeEffect;
  57798. protected _scene: Scene;
  57799. protected _engine: Engine;
  57800. protected _maxSize: number;
  57801. protected _mainTextureDesiredSize: ISize;
  57802. protected _mainTexture: RenderTargetTexture;
  57803. protected _shouldRender: boolean;
  57804. protected _postProcesses: PostProcess[];
  57805. protected _textures: BaseTexture[];
  57806. protected _emissiveTextureAndColor: {
  57807. texture: Nullable<BaseTexture>;
  57808. color: Color4;
  57809. };
  57810. /**
  57811. * The name of the layer
  57812. */
  57813. name: string;
  57814. /**
  57815. * The clear color of the texture used to generate the glow map.
  57816. */
  57817. neutralColor: Color4;
  57818. /**
  57819. * Specifies whether the highlight layer is enabled or not.
  57820. */
  57821. isEnabled: boolean;
  57822. /**
  57823. * Gets the camera attached to the layer.
  57824. */
  57825. get camera(): Nullable<Camera>;
  57826. /**
  57827. * Gets the rendering group id the layer should render in.
  57828. */
  57829. get renderingGroupId(): number;
  57830. set renderingGroupId(renderingGroupId: number);
  57831. /**
  57832. * An event triggered when the effect layer has been disposed.
  57833. */
  57834. onDisposeObservable: Observable<EffectLayer>;
  57835. /**
  57836. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57837. */
  57838. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57839. /**
  57840. * An event triggered when the generated texture is being merged in the scene.
  57841. */
  57842. onBeforeComposeObservable: Observable<EffectLayer>;
  57843. /**
  57844. * An event triggered when the mesh is rendered into the effect render target.
  57845. */
  57846. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57847. /**
  57848. * An event triggered after the mesh has been rendered into the effect render target.
  57849. */
  57850. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57851. /**
  57852. * An event triggered when the generated texture has been merged in the scene.
  57853. */
  57854. onAfterComposeObservable: Observable<EffectLayer>;
  57855. /**
  57856. * An event triggered when the efffect layer changes its size.
  57857. */
  57858. onSizeChangedObservable: Observable<EffectLayer>;
  57859. /** @hidden */
  57860. static _SceneComponentInitialization: (scene: Scene) => void;
  57861. /**
  57862. * Instantiates a new effect Layer and references it in the scene.
  57863. * @param name The name of the layer
  57864. * @param scene The scene to use the layer in
  57865. */
  57866. constructor(
  57867. /** The Friendly of the effect in the scene */
  57868. name: string, scene: Scene);
  57869. /**
  57870. * Get the effect name of the layer.
  57871. * @return The effect name
  57872. */
  57873. abstract getEffectName(): string;
  57874. /**
  57875. * Checks for the readiness of the element composing the layer.
  57876. * @param subMesh the mesh to check for
  57877. * @param useInstances specify whether or not to use instances to render the mesh
  57878. * @return true if ready otherwise, false
  57879. */
  57880. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57881. /**
  57882. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57883. * @returns true if the effect requires stencil during the main canvas render pass.
  57884. */
  57885. abstract needStencil(): boolean;
  57886. /**
  57887. * Create the merge effect. This is the shader use to blit the information back
  57888. * to the main canvas at the end of the scene rendering.
  57889. * @returns The effect containing the shader used to merge the effect on the main canvas
  57890. */
  57891. protected abstract _createMergeEffect(): Effect;
  57892. /**
  57893. * Creates the render target textures and post processes used in the effect layer.
  57894. */
  57895. protected abstract _createTextureAndPostProcesses(): void;
  57896. /**
  57897. * Implementation specific of rendering the generating effect on the main canvas.
  57898. * @param effect The effect used to render through
  57899. */
  57900. protected abstract _internalRender(effect: Effect): void;
  57901. /**
  57902. * Sets the required values for both the emissive texture and and the main color.
  57903. */
  57904. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57905. /**
  57906. * Free any resources and references associated to a mesh.
  57907. * Internal use
  57908. * @param mesh The mesh to free.
  57909. */
  57910. abstract _disposeMesh(mesh: Mesh): void;
  57911. /**
  57912. * Serializes this layer (Glow or Highlight for example)
  57913. * @returns a serialized layer object
  57914. */
  57915. abstract serialize?(): any;
  57916. /**
  57917. * Initializes the effect layer with the required options.
  57918. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57919. */
  57920. protected _init(options: Partial<IEffectLayerOptions>): void;
  57921. /**
  57922. * Generates the index buffer of the full screen quad blending to the main canvas.
  57923. */
  57924. private _generateIndexBuffer;
  57925. /**
  57926. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57927. */
  57928. private _generateVertexBuffer;
  57929. /**
  57930. * Sets the main texture desired size which is the closest power of two
  57931. * of the engine canvas size.
  57932. */
  57933. private _setMainTextureSize;
  57934. /**
  57935. * Creates the main texture for the effect layer.
  57936. */
  57937. protected _createMainTexture(): void;
  57938. /**
  57939. * Adds specific effects defines.
  57940. * @param defines The defines to add specifics to.
  57941. */
  57942. protected _addCustomEffectDefines(defines: string[]): void;
  57943. /**
  57944. * Checks for the readiness of the element composing the layer.
  57945. * @param subMesh the mesh to check for
  57946. * @param useInstances specify whether or not to use instances to render the mesh
  57947. * @param emissiveTexture the associated emissive texture used to generate the glow
  57948. * @return true if ready otherwise, false
  57949. */
  57950. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57951. /**
  57952. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57953. */
  57954. render(): void;
  57955. /**
  57956. * Determine if a given mesh will be used in the current effect.
  57957. * @param mesh mesh to test
  57958. * @returns true if the mesh will be used
  57959. */
  57960. hasMesh(mesh: AbstractMesh): boolean;
  57961. /**
  57962. * Returns true if the layer contains information to display, otherwise false.
  57963. * @returns true if the glow layer should be rendered
  57964. */
  57965. shouldRender(): boolean;
  57966. /**
  57967. * Returns true if the mesh should render, otherwise false.
  57968. * @param mesh The mesh to render
  57969. * @returns true if it should render otherwise false
  57970. */
  57971. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57972. /**
  57973. * Returns true if the mesh can be rendered, otherwise false.
  57974. * @param mesh The mesh to render
  57975. * @param material The material used on the mesh
  57976. * @returns true if it can be rendered otherwise false
  57977. */
  57978. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57979. /**
  57980. * Returns true if the mesh should render, otherwise false.
  57981. * @param mesh The mesh to render
  57982. * @returns true if it should render otherwise false
  57983. */
  57984. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57985. /**
  57986. * Renders the submesh passed in parameter to the generation map.
  57987. */
  57988. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57989. /**
  57990. * Defines whether the current material of the mesh should be use to render the effect.
  57991. * @param mesh defines the current mesh to render
  57992. */
  57993. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57994. /**
  57995. * Rebuild the required buffers.
  57996. * @hidden Internal use only.
  57997. */
  57998. _rebuild(): void;
  57999. /**
  58000. * Dispose only the render target textures and post process.
  58001. */
  58002. private _disposeTextureAndPostProcesses;
  58003. /**
  58004. * Dispose the highlight layer and free resources.
  58005. */
  58006. dispose(): void;
  58007. /**
  58008. * Gets the class name of the effect layer
  58009. * @returns the string with the class name of the effect layer
  58010. */
  58011. getClassName(): string;
  58012. /**
  58013. * Creates an effect layer from parsed effect layer data
  58014. * @param parsedEffectLayer defines effect layer data
  58015. * @param scene defines the current scene
  58016. * @param rootUrl defines the root URL containing the effect layer information
  58017. * @returns a parsed effect Layer
  58018. */
  58019. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58020. }
  58021. }
  58022. declare module BABYLON {
  58023. interface AbstractScene {
  58024. /**
  58025. * The list of effect layers (highlights/glow) added to the scene
  58026. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58027. * @see https://doc.babylonjs.com/how_to/glow_layer
  58028. */
  58029. effectLayers: Array<EffectLayer>;
  58030. /**
  58031. * Removes the given effect layer from this scene.
  58032. * @param toRemove defines the effect layer to remove
  58033. * @returns the index of the removed effect layer
  58034. */
  58035. removeEffectLayer(toRemove: EffectLayer): number;
  58036. /**
  58037. * Adds the given effect layer to this scene
  58038. * @param newEffectLayer defines the effect layer to add
  58039. */
  58040. addEffectLayer(newEffectLayer: EffectLayer): void;
  58041. }
  58042. /**
  58043. * Defines the layer scene component responsible to manage any effect layers
  58044. * in a given scene.
  58045. */
  58046. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58047. /**
  58048. * The component name helpfull to identify the component in the list of scene components.
  58049. */
  58050. readonly name: string;
  58051. /**
  58052. * The scene the component belongs to.
  58053. */
  58054. scene: Scene;
  58055. private _engine;
  58056. private _renderEffects;
  58057. private _needStencil;
  58058. private _previousStencilState;
  58059. /**
  58060. * Creates a new instance of the component for the given scene
  58061. * @param scene Defines the scene to register the component in
  58062. */
  58063. constructor(scene: Scene);
  58064. /**
  58065. * Registers the component in a given scene
  58066. */
  58067. register(): void;
  58068. /**
  58069. * Rebuilds the elements related to this component in case of
  58070. * context lost for instance.
  58071. */
  58072. rebuild(): void;
  58073. /**
  58074. * Serializes the component data to the specified json object
  58075. * @param serializationObject The object to serialize to
  58076. */
  58077. serialize(serializationObject: any): void;
  58078. /**
  58079. * Adds all the elements from the container to the scene
  58080. * @param container the container holding the elements
  58081. */
  58082. addFromContainer(container: AbstractScene): void;
  58083. /**
  58084. * Removes all the elements in the container from the scene
  58085. * @param container contains the elements to remove
  58086. * @param dispose if the removed element should be disposed (default: false)
  58087. */
  58088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58089. /**
  58090. * Disposes the component and the associated ressources.
  58091. */
  58092. dispose(): void;
  58093. private _isReadyForMesh;
  58094. private _renderMainTexture;
  58095. private _setStencil;
  58096. private _setStencilBack;
  58097. private _draw;
  58098. private _drawCamera;
  58099. private _drawRenderingGroup;
  58100. }
  58101. }
  58102. declare module BABYLON {
  58103. /** @hidden */
  58104. export var glowMapMergePixelShader: {
  58105. name: string;
  58106. shader: string;
  58107. };
  58108. }
  58109. declare module BABYLON {
  58110. /** @hidden */
  58111. export var glowMapMergeVertexShader: {
  58112. name: string;
  58113. shader: string;
  58114. };
  58115. }
  58116. declare module BABYLON {
  58117. interface AbstractScene {
  58118. /**
  58119. * Return a the first highlight layer of the scene with a given name.
  58120. * @param name The name of the highlight layer to look for.
  58121. * @return The highlight layer if found otherwise null.
  58122. */
  58123. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58124. }
  58125. /**
  58126. * Glow layer options. This helps customizing the behaviour
  58127. * of the glow layer.
  58128. */
  58129. export interface IGlowLayerOptions {
  58130. /**
  58131. * Multiplication factor apply to the canvas size to compute the render target size
  58132. * used to generated the glowing objects (the smaller the faster).
  58133. */
  58134. mainTextureRatio: number;
  58135. /**
  58136. * Enforces a fixed size texture to ensure resize independant blur.
  58137. */
  58138. mainTextureFixedSize?: number;
  58139. /**
  58140. * How big is the kernel of the blur texture.
  58141. */
  58142. blurKernelSize: number;
  58143. /**
  58144. * The camera attached to the layer.
  58145. */
  58146. camera: Nullable<Camera>;
  58147. /**
  58148. * Enable MSAA by chosing the number of samples.
  58149. */
  58150. mainTextureSamples?: number;
  58151. /**
  58152. * The rendering group to draw the layer in.
  58153. */
  58154. renderingGroupId: number;
  58155. }
  58156. /**
  58157. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58158. *
  58159. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58160. *
  58161. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58162. */
  58163. export class GlowLayer extends EffectLayer {
  58164. /**
  58165. * Effect Name of the layer.
  58166. */
  58167. static readonly EffectName: string;
  58168. /**
  58169. * The default blur kernel size used for the glow.
  58170. */
  58171. static DefaultBlurKernelSize: number;
  58172. /**
  58173. * The default texture size ratio used for the glow.
  58174. */
  58175. static DefaultTextureRatio: number;
  58176. /**
  58177. * Sets the kernel size of the blur.
  58178. */
  58179. set blurKernelSize(value: number);
  58180. /**
  58181. * Gets the kernel size of the blur.
  58182. */
  58183. get blurKernelSize(): number;
  58184. /**
  58185. * Sets the glow intensity.
  58186. */
  58187. set intensity(value: number);
  58188. /**
  58189. * Gets the glow intensity.
  58190. */
  58191. get intensity(): number;
  58192. private _options;
  58193. private _intensity;
  58194. private _horizontalBlurPostprocess1;
  58195. private _verticalBlurPostprocess1;
  58196. private _horizontalBlurPostprocess2;
  58197. private _verticalBlurPostprocess2;
  58198. private _blurTexture1;
  58199. private _blurTexture2;
  58200. private _postProcesses1;
  58201. private _postProcesses2;
  58202. private _includedOnlyMeshes;
  58203. private _excludedMeshes;
  58204. private _meshesUsingTheirOwnMaterials;
  58205. /**
  58206. * Callback used to let the user override the color selection on a per mesh basis
  58207. */
  58208. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58209. /**
  58210. * Callback used to let the user override the texture selection on a per mesh basis
  58211. */
  58212. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58213. /**
  58214. * Instantiates a new glow Layer and references it to the scene.
  58215. * @param name The name of the layer
  58216. * @param scene The scene to use the layer in
  58217. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58218. */
  58219. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58220. /**
  58221. * Get the effect name of the layer.
  58222. * @return The effect name
  58223. */
  58224. getEffectName(): string;
  58225. /**
  58226. * Create the merge effect. This is the shader use to blit the information back
  58227. * to the main canvas at the end of the scene rendering.
  58228. */
  58229. protected _createMergeEffect(): Effect;
  58230. /**
  58231. * Creates the render target textures and post processes used in the glow layer.
  58232. */
  58233. protected _createTextureAndPostProcesses(): void;
  58234. /**
  58235. * Checks for the readiness of the element composing the layer.
  58236. * @param subMesh the mesh to check for
  58237. * @param useInstances specify wether or not to use instances to render the mesh
  58238. * @param emissiveTexture the associated emissive texture used to generate the glow
  58239. * @return true if ready otherwise, false
  58240. */
  58241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58242. /**
  58243. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58244. */
  58245. needStencil(): boolean;
  58246. /**
  58247. * Returns true if the mesh can be rendered, otherwise false.
  58248. * @param mesh The mesh to render
  58249. * @param material The material used on the mesh
  58250. * @returns true if it can be rendered otherwise false
  58251. */
  58252. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58253. /**
  58254. * Implementation specific of rendering the generating effect on the main canvas.
  58255. * @param effect The effect used to render through
  58256. */
  58257. protected _internalRender(effect: Effect): void;
  58258. /**
  58259. * Sets the required values for both the emissive texture and and the main color.
  58260. */
  58261. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58262. /**
  58263. * Returns true if the mesh should render, otherwise false.
  58264. * @param mesh The mesh to render
  58265. * @returns true if it should render otherwise false
  58266. */
  58267. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58268. /**
  58269. * Adds specific effects defines.
  58270. * @param defines The defines to add specifics to.
  58271. */
  58272. protected _addCustomEffectDefines(defines: string[]): void;
  58273. /**
  58274. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58275. * @param mesh The mesh to exclude from the glow layer
  58276. */
  58277. addExcludedMesh(mesh: Mesh): void;
  58278. /**
  58279. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58280. * @param mesh The mesh to remove
  58281. */
  58282. removeExcludedMesh(mesh: Mesh): void;
  58283. /**
  58284. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58285. * @param mesh The mesh to include in the glow layer
  58286. */
  58287. addIncludedOnlyMesh(mesh: Mesh): void;
  58288. /**
  58289. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58290. * @param mesh The mesh to remove
  58291. */
  58292. removeIncludedOnlyMesh(mesh: Mesh): void;
  58293. /**
  58294. * Determine if a given mesh will be used in the glow layer
  58295. * @param mesh The mesh to test
  58296. * @returns true if the mesh will be highlighted by the current glow layer
  58297. */
  58298. hasMesh(mesh: AbstractMesh): boolean;
  58299. /**
  58300. * Defines whether the current material of the mesh should be use to render the effect.
  58301. * @param mesh defines the current mesh to render
  58302. */
  58303. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58304. /**
  58305. * Add a mesh to be rendered through its own material and not with emissive only.
  58306. * @param mesh The mesh for which we need to use its material
  58307. */
  58308. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58309. /**
  58310. * Remove a mesh from being rendered through its own material and not with emissive only.
  58311. * @param mesh The mesh for which we need to not use its material
  58312. */
  58313. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58314. /**
  58315. * Free any resources and references associated to a mesh.
  58316. * Internal use
  58317. * @param mesh The mesh to free.
  58318. * @hidden
  58319. */
  58320. _disposeMesh(mesh: Mesh): void;
  58321. /**
  58322. * Gets the class name of the effect layer
  58323. * @returns the string with the class name of the effect layer
  58324. */
  58325. getClassName(): string;
  58326. /**
  58327. * Serializes this glow layer
  58328. * @returns a serialized glow layer object
  58329. */
  58330. serialize(): any;
  58331. /**
  58332. * Creates a Glow Layer from parsed glow layer data
  58333. * @param parsedGlowLayer defines glow layer data
  58334. * @param scene defines the current scene
  58335. * @param rootUrl defines the root URL containing the glow layer information
  58336. * @returns a parsed Glow Layer
  58337. */
  58338. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58339. }
  58340. }
  58341. declare module BABYLON {
  58342. /** @hidden */
  58343. export var glowBlurPostProcessPixelShader: {
  58344. name: string;
  58345. shader: string;
  58346. };
  58347. }
  58348. declare module BABYLON {
  58349. interface AbstractScene {
  58350. /**
  58351. * Return a the first highlight layer of the scene with a given name.
  58352. * @param name The name of the highlight layer to look for.
  58353. * @return The highlight layer if found otherwise null.
  58354. */
  58355. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58356. }
  58357. /**
  58358. * Highlight layer options. This helps customizing the behaviour
  58359. * of the highlight layer.
  58360. */
  58361. export interface IHighlightLayerOptions {
  58362. /**
  58363. * Multiplication factor apply to the canvas size to compute the render target size
  58364. * used to generated the glowing objects (the smaller the faster).
  58365. */
  58366. mainTextureRatio: number;
  58367. /**
  58368. * Enforces a fixed size texture to ensure resize independant blur.
  58369. */
  58370. mainTextureFixedSize?: number;
  58371. /**
  58372. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58373. * of the picture to blur (the smaller the faster).
  58374. */
  58375. blurTextureSizeRatio: number;
  58376. /**
  58377. * How big in texel of the blur texture is the vertical blur.
  58378. */
  58379. blurVerticalSize: number;
  58380. /**
  58381. * How big in texel of the blur texture is the horizontal blur.
  58382. */
  58383. blurHorizontalSize: number;
  58384. /**
  58385. * Alpha blending mode used to apply the blur. Default is combine.
  58386. */
  58387. alphaBlendingMode: number;
  58388. /**
  58389. * The camera attached to the layer.
  58390. */
  58391. camera: Nullable<Camera>;
  58392. /**
  58393. * Should we display highlight as a solid stroke?
  58394. */
  58395. isStroke?: boolean;
  58396. /**
  58397. * The rendering group to draw the layer in.
  58398. */
  58399. renderingGroupId: number;
  58400. }
  58401. /**
  58402. * The highlight layer Helps adding a glow effect around a mesh.
  58403. *
  58404. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58405. * glowy meshes to your scene.
  58406. *
  58407. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58408. */
  58409. export class HighlightLayer extends EffectLayer {
  58410. name: string;
  58411. /**
  58412. * Effect Name of the highlight layer.
  58413. */
  58414. static readonly EffectName: string;
  58415. /**
  58416. * The neutral color used during the preparation of the glow effect.
  58417. * This is black by default as the blend operation is a blend operation.
  58418. */
  58419. static NeutralColor: Color4;
  58420. /**
  58421. * Stencil value used for glowing meshes.
  58422. */
  58423. static GlowingMeshStencilReference: number;
  58424. /**
  58425. * Stencil value used for the other meshes in the scene.
  58426. */
  58427. static NormalMeshStencilReference: number;
  58428. /**
  58429. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58430. */
  58431. innerGlow: boolean;
  58432. /**
  58433. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58434. */
  58435. outerGlow: boolean;
  58436. /**
  58437. * Specifies the horizontal size of the blur.
  58438. */
  58439. set blurHorizontalSize(value: number);
  58440. /**
  58441. * Specifies the vertical size of the blur.
  58442. */
  58443. set blurVerticalSize(value: number);
  58444. /**
  58445. * Gets the horizontal size of the blur.
  58446. */
  58447. get blurHorizontalSize(): number;
  58448. /**
  58449. * Gets the vertical size of the blur.
  58450. */
  58451. get blurVerticalSize(): number;
  58452. /**
  58453. * An event triggered when the highlight layer is being blurred.
  58454. */
  58455. onBeforeBlurObservable: Observable<HighlightLayer>;
  58456. /**
  58457. * An event triggered when the highlight layer has been blurred.
  58458. */
  58459. onAfterBlurObservable: Observable<HighlightLayer>;
  58460. private _instanceGlowingMeshStencilReference;
  58461. private _options;
  58462. private _downSamplePostprocess;
  58463. private _horizontalBlurPostprocess;
  58464. private _verticalBlurPostprocess;
  58465. private _blurTexture;
  58466. private _meshes;
  58467. private _excludedMeshes;
  58468. /**
  58469. * Instantiates a new highlight Layer and references it to the scene..
  58470. * @param name The name of the layer
  58471. * @param scene The scene to use the layer in
  58472. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58473. */
  58474. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58475. /**
  58476. * Get the effect name of the layer.
  58477. * @return The effect name
  58478. */
  58479. getEffectName(): string;
  58480. /**
  58481. * Create the merge effect. This is the shader use to blit the information back
  58482. * to the main canvas at the end of the scene rendering.
  58483. */
  58484. protected _createMergeEffect(): Effect;
  58485. /**
  58486. * Creates the render target textures and post processes used in the highlight layer.
  58487. */
  58488. protected _createTextureAndPostProcesses(): void;
  58489. /**
  58490. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58491. */
  58492. needStencil(): boolean;
  58493. /**
  58494. * Checks for the readiness of the element composing the layer.
  58495. * @param subMesh the mesh to check for
  58496. * @param useInstances specify wether or not to use instances to render the mesh
  58497. * @param emissiveTexture the associated emissive texture used to generate the glow
  58498. * @return true if ready otherwise, false
  58499. */
  58500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58501. /**
  58502. * Implementation specific of rendering the generating effect on the main canvas.
  58503. * @param effect The effect used to render through
  58504. */
  58505. protected _internalRender(effect: Effect): void;
  58506. /**
  58507. * Returns true if the layer contains information to display, otherwise false.
  58508. */
  58509. shouldRender(): boolean;
  58510. /**
  58511. * Returns true if the mesh should render, otherwise false.
  58512. * @param mesh The mesh to render
  58513. * @returns true if it should render otherwise false
  58514. */
  58515. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58516. /**
  58517. * Returns true if the mesh can be rendered, otherwise false.
  58518. * @param mesh The mesh to render
  58519. * @param material The material used on the mesh
  58520. * @returns true if it can be rendered otherwise false
  58521. */
  58522. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58523. /**
  58524. * Adds specific effects defines.
  58525. * @param defines The defines to add specifics to.
  58526. */
  58527. protected _addCustomEffectDefines(defines: string[]): void;
  58528. /**
  58529. * Sets the required values for both the emissive texture and and the main color.
  58530. */
  58531. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58532. /**
  58533. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58534. * @param mesh The mesh to exclude from the highlight layer
  58535. */
  58536. addExcludedMesh(mesh: Mesh): void;
  58537. /**
  58538. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58539. * @param mesh The mesh to highlight
  58540. */
  58541. removeExcludedMesh(mesh: Mesh): void;
  58542. /**
  58543. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58544. * @param mesh mesh to test
  58545. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58546. */
  58547. hasMesh(mesh: AbstractMesh): boolean;
  58548. /**
  58549. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58550. * @param mesh The mesh to highlight
  58551. * @param color The color of the highlight
  58552. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58553. */
  58554. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58555. /**
  58556. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58557. * @param mesh The mesh to highlight
  58558. */
  58559. removeMesh(mesh: Mesh): void;
  58560. /**
  58561. * Remove all the meshes currently referenced in the highlight layer
  58562. */
  58563. removeAllMeshes(): void;
  58564. /**
  58565. * Force the stencil to the normal expected value for none glowing parts
  58566. */
  58567. private _defaultStencilReference;
  58568. /**
  58569. * Free any resources and references associated to a mesh.
  58570. * Internal use
  58571. * @param mesh The mesh to free.
  58572. * @hidden
  58573. */
  58574. _disposeMesh(mesh: Mesh): void;
  58575. /**
  58576. * Dispose the highlight layer and free resources.
  58577. */
  58578. dispose(): void;
  58579. /**
  58580. * Gets the class name of the effect layer
  58581. * @returns the string with the class name of the effect layer
  58582. */
  58583. getClassName(): string;
  58584. /**
  58585. * Serializes this Highlight layer
  58586. * @returns a serialized Highlight layer object
  58587. */
  58588. serialize(): any;
  58589. /**
  58590. * Creates a Highlight layer from parsed Highlight layer data
  58591. * @param parsedHightlightLayer defines the Highlight layer data
  58592. * @param scene defines the current scene
  58593. * @param rootUrl defines the root URL containing the Highlight layer information
  58594. * @returns a parsed Highlight layer
  58595. */
  58596. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58597. }
  58598. }
  58599. declare module BABYLON {
  58600. interface AbstractScene {
  58601. /**
  58602. * The list of layers (background and foreground) of the scene
  58603. */
  58604. layers: Array<Layer>;
  58605. }
  58606. /**
  58607. * Defines the layer scene component responsible to manage any layers
  58608. * in a given scene.
  58609. */
  58610. export class LayerSceneComponent implements ISceneComponent {
  58611. /**
  58612. * The component name helpfull to identify the component in the list of scene components.
  58613. */
  58614. readonly name: string;
  58615. /**
  58616. * The scene the component belongs to.
  58617. */
  58618. scene: Scene;
  58619. private _engine;
  58620. /**
  58621. * Creates a new instance of the component for the given scene
  58622. * @param scene Defines the scene to register the component in
  58623. */
  58624. constructor(scene: Scene);
  58625. /**
  58626. * Registers the component in a given scene
  58627. */
  58628. register(): void;
  58629. /**
  58630. * Rebuilds the elements related to this component in case of
  58631. * context lost for instance.
  58632. */
  58633. rebuild(): void;
  58634. /**
  58635. * Disposes the component and the associated ressources.
  58636. */
  58637. dispose(): void;
  58638. private _draw;
  58639. private _drawCameraPredicate;
  58640. private _drawCameraBackground;
  58641. private _drawCameraForeground;
  58642. private _drawRenderTargetPredicate;
  58643. private _drawRenderTargetBackground;
  58644. private _drawRenderTargetForeground;
  58645. /**
  58646. * Adds all the elements from the container to the scene
  58647. * @param container the container holding the elements
  58648. */
  58649. addFromContainer(container: AbstractScene): void;
  58650. /**
  58651. * Removes all the elements in the container from the scene
  58652. * @param container contains the elements to remove
  58653. * @param dispose if the removed element should be disposed (default: false)
  58654. */
  58655. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58656. }
  58657. }
  58658. declare module BABYLON {
  58659. /** @hidden */
  58660. export var layerPixelShader: {
  58661. name: string;
  58662. shader: string;
  58663. };
  58664. }
  58665. declare module BABYLON {
  58666. /** @hidden */
  58667. export var layerVertexShader: {
  58668. name: string;
  58669. shader: string;
  58670. };
  58671. }
  58672. declare module BABYLON {
  58673. /**
  58674. * This represents a full screen 2d layer.
  58675. * This can be useful to display a picture in the background of your scene for instance.
  58676. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58677. */
  58678. export class Layer {
  58679. /**
  58680. * Define the name of the layer.
  58681. */
  58682. name: string;
  58683. /**
  58684. * Define the texture the layer should display.
  58685. */
  58686. texture: Nullable<Texture>;
  58687. /**
  58688. * Is the layer in background or foreground.
  58689. */
  58690. isBackground: boolean;
  58691. /**
  58692. * Define the color of the layer (instead of texture).
  58693. */
  58694. color: Color4;
  58695. /**
  58696. * Define the scale of the layer in order to zoom in out of the texture.
  58697. */
  58698. scale: Vector2;
  58699. /**
  58700. * Define an offset for the layer in order to shift the texture.
  58701. */
  58702. offset: Vector2;
  58703. /**
  58704. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58705. */
  58706. alphaBlendingMode: number;
  58707. /**
  58708. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58709. * Alpha test will not mix with the background color in case of transparency.
  58710. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58711. */
  58712. alphaTest: boolean;
  58713. /**
  58714. * Define a mask to restrict the layer to only some of the scene cameras.
  58715. */
  58716. layerMask: number;
  58717. /**
  58718. * Define the list of render target the layer is visible into.
  58719. */
  58720. renderTargetTextures: RenderTargetTexture[];
  58721. /**
  58722. * Define if the layer is only used in renderTarget or if it also
  58723. * renders in the main frame buffer of the canvas.
  58724. */
  58725. renderOnlyInRenderTargetTextures: boolean;
  58726. private _scene;
  58727. private _vertexBuffers;
  58728. private _indexBuffer;
  58729. private _effect;
  58730. private _previousDefines;
  58731. /**
  58732. * An event triggered when the layer is disposed.
  58733. */
  58734. onDisposeObservable: Observable<Layer>;
  58735. private _onDisposeObserver;
  58736. /**
  58737. * Back compatibility with callback before the onDisposeObservable existed.
  58738. * The set callback will be triggered when the layer has been disposed.
  58739. */
  58740. set onDispose(callback: () => void);
  58741. /**
  58742. * An event triggered before rendering the scene
  58743. */
  58744. onBeforeRenderObservable: Observable<Layer>;
  58745. private _onBeforeRenderObserver;
  58746. /**
  58747. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58748. * The set callback will be triggered just before rendering the layer.
  58749. */
  58750. set onBeforeRender(callback: () => void);
  58751. /**
  58752. * An event triggered after rendering the scene
  58753. */
  58754. onAfterRenderObservable: Observable<Layer>;
  58755. private _onAfterRenderObserver;
  58756. /**
  58757. * Back compatibility with callback before the onAfterRenderObservable existed.
  58758. * The set callback will be triggered just after rendering the layer.
  58759. */
  58760. set onAfterRender(callback: () => void);
  58761. /**
  58762. * Instantiates a new layer.
  58763. * This represents a full screen 2d layer.
  58764. * This can be useful to display a picture in the background of your scene for instance.
  58765. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58766. * @param name Define the name of the layer in the scene
  58767. * @param imgUrl Define the url of the texture to display in the layer
  58768. * @param scene Define the scene the layer belongs to
  58769. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58770. * @param color Defines a color for the layer
  58771. */
  58772. constructor(
  58773. /**
  58774. * Define the name of the layer.
  58775. */
  58776. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58777. private _createIndexBuffer;
  58778. /** @hidden */
  58779. _rebuild(): void;
  58780. /**
  58781. * Renders the layer in the scene.
  58782. */
  58783. render(): void;
  58784. /**
  58785. * Disposes and releases the associated ressources.
  58786. */
  58787. dispose(): void;
  58788. }
  58789. }
  58790. declare module BABYLON {
  58791. /** @hidden */
  58792. export var lensFlarePixelShader: {
  58793. name: string;
  58794. shader: string;
  58795. };
  58796. }
  58797. declare module BABYLON {
  58798. /** @hidden */
  58799. export var lensFlareVertexShader: {
  58800. name: string;
  58801. shader: string;
  58802. };
  58803. }
  58804. declare module BABYLON {
  58805. /**
  58806. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58807. * It is usually composed of several `lensFlare`.
  58808. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58809. */
  58810. export class LensFlareSystem {
  58811. /**
  58812. * Define the name of the lens flare system
  58813. */
  58814. name: string;
  58815. /**
  58816. * List of lens flares used in this system.
  58817. */
  58818. lensFlares: LensFlare[];
  58819. /**
  58820. * Define a limit from the border the lens flare can be visible.
  58821. */
  58822. borderLimit: number;
  58823. /**
  58824. * Define a viewport border we do not want to see the lens flare in.
  58825. */
  58826. viewportBorder: number;
  58827. /**
  58828. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58829. */
  58830. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58831. /**
  58832. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58833. */
  58834. layerMask: number;
  58835. /**
  58836. * Define the id of the lens flare system in the scene.
  58837. * (equal to name by default)
  58838. */
  58839. id: string;
  58840. private _scene;
  58841. private _emitter;
  58842. private _vertexBuffers;
  58843. private _indexBuffer;
  58844. private _effect;
  58845. private _positionX;
  58846. private _positionY;
  58847. private _isEnabled;
  58848. /** @hidden */
  58849. static _SceneComponentInitialization: (scene: Scene) => void;
  58850. /**
  58851. * Instantiates a lens flare system.
  58852. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58853. * It is usually composed of several `lensFlare`.
  58854. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58855. * @param name Define the name of the lens flare system in the scene
  58856. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58857. * @param scene Define the scene the lens flare system belongs to
  58858. */
  58859. constructor(
  58860. /**
  58861. * Define the name of the lens flare system
  58862. */
  58863. name: string, emitter: any, scene: Scene);
  58864. /**
  58865. * Define if the lens flare system is enabled.
  58866. */
  58867. get isEnabled(): boolean;
  58868. set isEnabled(value: boolean);
  58869. /**
  58870. * Get the scene the effects belongs to.
  58871. * @returns the scene holding the lens flare system
  58872. */
  58873. getScene(): Scene;
  58874. /**
  58875. * Get the emitter of the lens flare system.
  58876. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58877. * @returns the emitter of the lens flare system
  58878. */
  58879. getEmitter(): any;
  58880. /**
  58881. * Set the emitter of the lens flare system.
  58882. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58883. * @param newEmitter Define the new emitter of the system
  58884. */
  58885. setEmitter(newEmitter: any): void;
  58886. /**
  58887. * Get the lens flare system emitter position.
  58888. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58889. * @returns the position
  58890. */
  58891. getEmitterPosition(): Vector3;
  58892. /**
  58893. * @hidden
  58894. */
  58895. computeEffectivePosition(globalViewport: Viewport): boolean;
  58896. /** @hidden */
  58897. _isVisible(): boolean;
  58898. /**
  58899. * @hidden
  58900. */
  58901. render(): boolean;
  58902. /**
  58903. * Dispose and release the lens flare with its associated resources.
  58904. */
  58905. dispose(): void;
  58906. /**
  58907. * Parse a lens flare system from a JSON repressentation
  58908. * @param parsedLensFlareSystem Define the JSON to parse
  58909. * @param scene Define the scene the parsed system should be instantiated in
  58910. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58911. * @returns the parsed system
  58912. */
  58913. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58914. /**
  58915. * Serialize the current Lens Flare System into a JSON representation.
  58916. * @returns the serialized JSON
  58917. */
  58918. serialize(): any;
  58919. }
  58920. }
  58921. declare module BABYLON {
  58922. /**
  58923. * This represents one of the lens effect in a `lensFlareSystem`.
  58924. * It controls one of the indiviual texture used in the effect.
  58925. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58926. */
  58927. export class LensFlare {
  58928. /**
  58929. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58930. */
  58931. size: number;
  58932. /**
  58933. * 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.
  58934. */
  58935. position: number;
  58936. /**
  58937. * Define the lens color.
  58938. */
  58939. color: Color3;
  58940. /**
  58941. * Define the lens texture.
  58942. */
  58943. texture: Nullable<Texture>;
  58944. /**
  58945. * Define the alpha mode to render this particular lens.
  58946. */
  58947. alphaMode: number;
  58948. private _system;
  58949. /**
  58950. * Creates a new Lens Flare.
  58951. * This represents one of the lens effect in a `lensFlareSystem`.
  58952. * It controls one of the indiviual texture used in the effect.
  58953. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58954. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58955. * @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.
  58956. * @param color Define the lens color
  58957. * @param imgUrl Define the lens texture url
  58958. * @param system Define the `lensFlareSystem` this flare is part of
  58959. * @returns The newly created Lens Flare
  58960. */
  58961. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58962. /**
  58963. * Instantiates a new Lens Flare.
  58964. * This represents one of the lens effect in a `lensFlareSystem`.
  58965. * It controls one of the indiviual texture used in the effect.
  58966. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58967. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58968. * @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.
  58969. * @param color Define the lens color
  58970. * @param imgUrl Define the lens texture url
  58971. * @param system Define the `lensFlareSystem` this flare is part of
  58972. */
  58973. constructor(
  58974. /**
  58975. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58976. */
  58977. size: number,
  58978. /**
  58979. * 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.
  58980. */
  58981. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58982. /**
  58983. * Dispose and release the lens flare with its associated resources.
  58984. */
  58985. dispose(): void;
  58986. }
  58987. }
  58988. declare module BABYLON {
  58989. interface AbstractScene {
  58990. /**
  58991. * The list of lens flare system added to the scene
  58992. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58993. */
  58994. lensFlareSystems: Array<LensFlareSystem>;
  58995. /**
  58996. * Removes the given lens flare system from this scene.
  58997. * @param toRemove The lens flare system to remove
  58998. * @returns The index of the removed lens flare system
  58999. */
  59000. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59001. /**
  59002. * Adds the given lens flare system to this scene
  59003. * @param newLensFlareSystem The lens flare system to add
  59004. */
  59005. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59006. /**
  59007. * Gets a lens flare system using its name
  59008. * @param name defines the name to look for
  59009. * @returns the lens flare system or null if not found
  59010. */
  59011. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59012. /**
  59013. * Gets a lens flare system using its id
  59014. * @param id defines the id to look for
  59015. * @returns the lens flare system or null if not found
  59016. */
  59017. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59018. }
  59019. /**
  59020. * Defines the lens flare scene component responsible to manage any lens flares
  59021. * in a given scene.
  59022. */
  59023. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59024. /**
  59025. * The component name helpfull to identify the component in the list of scene components.
  59026. */
  59027. readonly name: string;
  59028. /**
  59029. * The scene the component belongs to.
  59030. */
  59031. scene: Scene;
  59032. /**
  59033. * Creates a new instance of the component for the given scene
  59034. * @param scene Defines the scene to register the component in
  59035. */
  59036. constructor(scene: Scene);
  59037. /**
  59038. * Registers the component in a given scene
  59039. */
  59040. register(): void;
  59041. /**
  59042. * Rebuilds the elements related to this component in case of
  59043. * context lost for instance.
  59044. */
  59045. rebuild(): void;
  59046. /**
  59047. * Adds all the elements from the container to the scene
  59048. * @param container the container holding the elements
  59049. */
  59050. addFromContainer(container: AbstractScene): void;
  59051. /**
  59052. * Removes all the elements in the container from the scene
  59053. * @param container contains the elements to remove
  59054. * @param dispose if the removed element should be disposed (default: false)
  59055. */
  59056. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59057. /**
  59058. * Serializes the component data to the specified json object
  59059. * @param serializationObject The object to serialize to
  59060. */
  59061. serialize(serializationObject: any): void;
  59062. /**
  59063. * Disposes the component and the associated ressources.
  59064. */
  59065. dispose(): void;
  59066. private _draw;
  59067. }
  59068. }
  59069. declare module BABYLON {
  59070. /** @hidden */
  59071. export var depthPixelShader: {
  59072. name: string;
  59073. shader: string;
  59074. };
  59075. }
  59076. declare module BABYLON {
  59077. /** @hidden */
  59078. export var depthVertexShader: {
  59079. name: string;
  59080. shader: string;
  59081. };
  59082. }
  59083. declare module BABYLON {
  59084. /**
  59085. * This represents a depth renderer in Babylon.
  59086. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59087. */
  59088. export class DepthRenderer {
  59089. private _scene;
  59090. private _depthMap;
  59091. private _effect;
  59092. private readonly _storeNonLinearDepth;
  59093. private readonly _clearColor;
  59094. /** Get if the depth renderer is using packed depth or not */
  59095. readonly isPacked: boolean;
  59096. private _cachedDefines;
  59097. private _camera;
  59098. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59099. enabled: boolean;
  59100. /**
  59101. * Specifiess that the depth renderer will only be used within
  59102. * the camera it is created for.
  59103. * This can help forcing its rendering during the camera processing.
  59104. */
  59105. useOnlyInActiveCamera: boolean;
  59106. /** @hidden */
  59107. static _SceneComponentInitialization: (scene: Scene) => void;
  59108. /**
  59109. * Instantiates a depth renderer
  59110. * @param scene The scene the renderer belongs to
  59111. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59112. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59113. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59114. */
  59115. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59116. /**
  59117. * Creates the depth rendering effect and checks if the effect is ready.
  59118. * @param subMesh The submesh to be used to render the depth map of
  59119. * @param useInstances If multiple world instances should be used
  59120. * @returns if the depth renderer is ready to render the depth map
  59121. */
  59122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59123. /**
  59124. * Gets the texture which the depth map will be written to.
  59125. * @returns The depth map texture
  59126. */
  59127. getDepthMap(): RenderTargetTexture;
  59128. /**
  59129. * Disposes of the depth renderer.
  59130. */
  59131. dispose(): void;
  59132. }
  59133. }
  59134. declare module BABYLON {
  59135. /** @hidden */
  59136. export var minmaxReduxPixelShader: {
  59137. name: string;
  59138. shader: string;
  59139. };
  59140. }
  59141. declare module BABYLON {
  59142. /**
  59143. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59144. * and maximum values from all values of the texture.
  59145. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59146. * The source values are read from the red channel of the texture.
  59147. */
  59148. export class MinMaxReducer {
  59149. /**
  59150. * Observable triggered when the computation has been performed
  59151. */
  59152. onAfterReductionPerformed: Observable<{
  59153. min: number;
  59154. max: number;
  59155. }>;
  59156. protected _camera: Camera;
  59157. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59158. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59159. protected _postProcessManager: PostProcessManager;
  59160. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59161. protected _forceFullscreenViewport: boolean;
  59162. /**
  59163. * Creates a min/max reducer
  59164. * @param camera The camera to use for the post processes
  59165. */
  59166. constructor(camera: Camera);
  59167. /**
  59168. * Gets the texture used to read the values from.
  59169. */
  59170. get sourceTexture(): Nullable<RenderTargetTexture>;
  59171. /**
  59172. * Sets the source texture to read the values from.
  59173. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59174. * because in such textures '1' value must not be taken into account to compute the maximum
  59175. * as this value is used to clear the texture.
  59176. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59177. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59178. * @param depthRedux Indicates if the texture is a depth texture or not
  59179. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59180. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59181. */
  59182. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59183. /**
  59184. * Defines the refresh rate of the computation.
  59185. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59186. */
  59187. get refreshRate(): number;
  59188. set refreshRate(value: number);
  59189. protected _activated: boolean;
  59190. /**
  59191. * Gets the activation status of the reducer
  59192. */
  59193. get activated(): boolean;
  59194. /**
  59195. * Activates the reduction computation.
  59196. * When activated, the observers registered in onAfterReductionPerformed are
  59197. * called after the compuation is performed
  59198. */
  59199. activate(): void;
  59200. /**
  59201. * Deactivates the reduction computation.
  59202. */
  59203. deactivate(): void;
  59204. /**
  59205. * Disposes the min/max reducer
  59206. * @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.
  59207. */
  59208. dispose(disposeAll?: boolean): void;
  59209. }
  59210. }
  59211. declare module BABYLON {
  59212. /**
  59213. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59214. */
  59215. export class DepthReducer extends MinMaxReducer {
  59216. private _depthRenderer;
  59217. private _depthRendererId;
  59218. /**
  59219. * Gets the depth renderer used for the computation.
  59220. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59221. */
  59222. get depthRenderer(): Nullable<DepthRenderer>;
  59223. /**
  59224. * Creates a depth reducer
  59225. * @param camera The camera used to render the depth texture
  59226. */
  59227. constructor(camera: Camera);
  59228. /**
  59229. * Sets the depth renderer to use to generate the depth map
  59230. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59231. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59232. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59233. */
  59234. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59235. /** @hidden */
  59236. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59237. /**
  59238. * Activates the reduction computation.
  59239. * When activated, the observers registered in onAfterReductionPerformed are
  59240. * called after the compuation is performed
  59241. */
  59242. activate(): void;
  59243. /**
  59244. * Deactivates the reduction computation.
  59245. */
  59246. deactivate(): void;
  59247. /**
  59248. * Disposes the depth reducer
  59249. * @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.
  59250. */
  59251. dispose(disposeAll?: boolean): void;
  59252. }
  59253. }
  59254. declare module BABYLON {
  59255. /**
  59256. * A CSM implementation allowing casting shadows on large scenes.
  59257. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59258. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59259. */
  59260. export class CascadedShadowGenerator extends ShadowGenerator {
  59261. private static readonly frustumCornersNDCSpace;
  59262. /**
  59263. * Name of the CSM class
  59264. */
  59265. static CLASSNAME: string;
  59266. /**
  59267. * Defines the default number of cascades used by the CSM.
  59268. */
  59269. static readonly DEFAULT_CASCADES_COUNT: number;
  59270. /**
  59271. * Defines the minimum number of cascades used by the CSM.
  59272. */
  59273. static readonly MIN_CASCADES_COUNT: number;
  59274. /**
  59275. * Defines the maximum number of cascades used by the CSM.
  59276. */
  59277. static readonly MAX_CASCADES_COUNT: number;
  59278. protected _validateFilter(filter: number): number;
  59279. /**
  59280. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59281. */
  59282. penumbraDarkness: number;
  59283. private _numCascades;
  59284. /**
  59285. * Gets or set the number of cascades used by the CSM.
  59286. */
  59287. get numCascades(): number;
  59288. set numCascades(value: number);
  59289. /**
  59290. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59291. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59292. */
  59293. stabilizeCascades: boolean;
  59294. private _freezeShadowCastersBoundingInfo;
  59295. private _freezeShadowCastersBoundingInfoObservable;
  59296. /**
  59297. * Enables or disables the shadow casters bounding info computation.
  59298. * If your shadow casters don't move, you can disable this feature.
  59299. * If it is enabled, the bounding box computation is done every frame.
  59300. */
  59301. get freezeShadowCastersBoundingInfo(): boolean;
  59302. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59303. private _scbiMin;
  59304. private _scbiMax;
  59305. protected _computeShadowCastersBoundingInfo(): void;
  59306. protected _shadowCastersBoundingInfo: BoundingInfo;
  59307. /**
  59308. * Gets or sets the shadow casters bounding info.
  59309. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59310. * so that the system won't overwrite the bounds you provide
  59311. */
  59312. get shadowCastersBoundingInfo(): BoundingInfo;
  59313. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59314. protected _breaksAreDirty: boolean;
  59315. protected _minDistance: number;
  59316. protected _maxDistance: number;
  59317. /**
  59318. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59319. *
  59320. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59321. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59322. * @param min minimal distance for the breaks (default to 0.)
  59323. * @param max maximal distance for the breaks (default to 1.)
  59324. */
  59325. setMinMaxDistance(min: number, max: number): void;
  59326. /** Gets the minimal distance used in the cascade break computation */
  59327. get minDistance(): number;
  59328. /** Gets the maximal distance used in the cascade break computation */
  59329. get maxDistance(): number;
  59330. /**
  59331. * Gets the class name of that object
  59332. * @returns "CascadedShadowGenerator"
  59333. */
  59334. getClassName(): string;
  59335. private _cascadeMinExtents;
  59336. private _cascadeMaxExtents;
  59337. /**
  59338. * Gets a cascade minimum extents
  59339. * @param cascadeIndex index of the cascade
  59340. * @returns the minimum cascade extents
  59341. */
  59342. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59343. /**
  59344. * Gets a cascade maximum extents
  59345. * @param cascadeIndex index of the cascade
  59346. * @returns the maximum cascade extents
  59347. */
  59348. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59349. private _cascades;
  59350. private _currentLayer;
  59351. private _viewSpaceFrustumsZ;
  59352. private _viewMatrices;
  59353. private _projectionMatrices;
  59354. private _transformMatrices;
  59355. private _transformMatricesAsArray;
  59356. private _frustumLengths;
  59357. private _lightSizeUVCorrection;
  59358. private _depthCorrection;
  59359. private _frustumCornersWorldSpace;
  59360. private _frustumCenter;
  59361. private _shadowCameraPos;
  59362. private _shadowMaxZ;
  59363. /**
  59364. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59365. * It defaults to camera.maxZ
  59366. */
  59367. get shadowMaxZ(): number;
  59368. /**
  59369. * Sets the shadow max z distance.
  59370. */
  59371. set shadowMaxZ(value: number);
  59372. protected _debug: boolean;
  59373. /**
  59374. * Gets or sets the debug flag.
  59375. * When enabled, the cascades are materialized by different colors on the screen.
  59376. */
  59377. get debug(): boolean;
  59378. set debug(dbg: boolean);
  59379. private _depthClamp;
  59380. /**
  59381. * Gets or sets the depth clamping value.
  59382. *
  59383. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59384. * to account for the shadow casters far away.
  59385. *
  59386. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59387. */
  59388. get depthClamp(): boolean;
  59389. set depthClamp(value: boolean);
  59390. private _cascadeBlendPercentage;
  59391. /**
  59392. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59393. * It defaults to 0.1 (10% blending).
  59394. */
  59395. get cascadeBlendPercentage(): number;
  59396. set cascadeBlendPercentage(value: number);
  59397. private _lambda;
  59398. /**
  59399. * Gets or set the lambda parameter.
  59400. * This parameter is used to split the camera frustum and create the cascades.
  59401. * 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.
  59402. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59403. */
  59404. get lambda(): number;
  59405. set lambda(value: number);
  59406. /**
  59407. * Gets the view matrix corresponding to a given cascade
  59408. * @param cascadeNum cascade to retrieve the view matrix from
  59409. * @returns the cascade view matrix
  59410. */
  59411. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59412. /**
  59413. * Gets the projection matrix corresponding to a given cascade
  59414. * @param cascadeNum cascade to retrieve the projection matrix from
  59415. * @returns the cascade projection matrix
  59416. */
  59417. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59418. /**
  59419. * Gets the transformation matrix corresponding to a given cascade
  59420. * @param cascadeNum cascade to retrieve the transformation matrix from
  59421. * @returns the cascade transformation matrix
  59422. */
  59423. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59424. private _depthRenderer;
  59425. /**
  59426. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59427. *
  59428. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59429. *
  59430. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59431. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59432. * @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
  59433. */
  59434. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59435. private _depthReducer;
  59436. private _autoCalcDepthBounds;
  59437. /**
  59438. * Gets or sets the autoCalcDepthBounds property.
  59439. *
  59440. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59441. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59442. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59443. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59444. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59445. */
  59446. get autoCalcDepthBounds(): boolean;
  59447. set autoCalcDepthBounds(value: boolean);
  59448. /**
  59449. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59450. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59451. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59452. * for setting the refresh rate on the renderer yourself!
  59453. */
  59454. get autoCalcDepthBoundsRefreshRate(): number;
  59455. set autoCalcDepthBoundsRefreshRate(value: number);
  59456. /**
  59457. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59458. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59459. * you change the camera near/far planes!
  59460. */
  59461. splitFrustum(): void;
  59462. private _splitFrustum;
  59463. private _computeMatrices;
  59464. private _computeFrustumInWorldSpace;
  59465. private _computeCascadeFrustum;
  59466. /**
  59467. * Support test.
  59468. */
  59469. static get IsSupported(): boolean;
  59470. /** @hidden */
  59471. static _SceneComponentInitialization: (scene: Scene) => void;
  59472. /**
  59473. * Creates a Cascaded Shadow Generator object.
  59474. * A ShadowGenerator is the required tool to use the shadows.
  59475. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59476. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59477. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59478. * @param light The directional light object generating the shadows.
  59479. * @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.
  59480. */
  59481. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59482. protected _initializeGenerator(): void;
  59483. protected _createTargetRenderTexture(): void;
  59484. protected _initializeShadowMap(): void;
  59485. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59486. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59487. /**
  59488. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59489. * @param defines Defines of the material we want to update
  59490. * @param lightIndex Index of the light in the enabled light list of the material
  59491. */
  59492. prepareDefines(defines: any, lightIndex: number): void;
  59493. /**
  59494. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59495. * defined in the generator but impacting the effect).
  59496. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59497. * @param effect The effect we are binfing the information for
  59498. */
  59499. bindShadowLight(lightIndex: string, effect: Effect): void;
  59500. /**
  59501. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59502. * (eq to view projection * shadow projection matrices)
  59503. * @returns The transform matrix used to create the shadow map
  59504. */
  59505. getTransformMatrix(): Matrix;
  59506. /**
  59507. * Disposes the ShadowGenerator.
  59508. * Returns nothing.
  59509. */
  59510. dispose(): void;
  59511. /**
  59512. * Serializes the shadow generator setup to a json object.
  59513. * @returns The serialized JSON object
  59514. */
  59515. serialize(): any;
  59516. /**
  59517. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59518. * @param parsedShadowGenerator The JSON object to parse
  59519. * @param scene The scene to create the shadow map for
  59520. * @returns The parsed shadow generator
  59521. */
  59522. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59523. }
  59524. }
  59525. declare module BABYLON {
  59526. /**
  59527. * Defines the shadow generator component responsible to manage any shadow generators
  59528. * in a given scene.
  59529. */
  59530. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59531. /**
  59532. * The component name helpfull to identify the component in the list of scene components.
  59533. */
  59534. readonly name: string;
  59535. /**
  59536. * The scene the component belongs to.
  59537. */
  59538. scene: Scene;
  59539. /**
  59540. * Creates a new instance of the component for the given scene
  59541. * @param scene Defines the scene to register the component in
  59542. */
  59543. constructor(scene: Scene);
  59544. /**
  59545. * Registers the component in a given scene
  59546. */
  59547. register(): void;
  59548. /**
  59549. * Rebuilds the elements related to this component in case of
  59550. * context lost for instance.
  59551. */
  59552. rebuild(): void;
  59553. /**
  59554. * Serializes the component data to the specified json object
  59555. * @param serializationObject The object to serialize to
  59556. */
  59557. serialize(serializationObject: any): void;
  59558. /**
  59559. * Adds all the elements from the container to the scene
  59560. * @param container the container holding the elements
  59561. */
  59562. addFromContainer(container: AbstractScene): void;
  59563. /**
  59564. * Removes all the elements in the container from the scene
  59565. * @param container contains the elements to remove
  59566. * @param dispose if the removed element should be disposed (default: false)
  59567. */
  59568. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59569. /**
  59570. * Rebuilds the elements related to this component in case of
  59571. * context lost for instance.
  59572. */
  59573. dispose(): void;
  59574. private _gatherRenderTargets;
  59575. }
  59576. }
  59577. declare module BABYLON {
  59578. /**
  59579. * A point light is a light defined by an unique point in world space.
  59580. * The light is emitted in every direction from this point.
  59581. * A good example of a point light is a standard light bulb.
  59582. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59583. */
  59584. export class PointLight extends ShadowLight {
  59585. private _shadowAngle;
  59586. /**
  59587. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59588. * This specifies what angle the shadow will use to be created.
  59589. *
  59590. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59591. */
  59592. get shadowAngle(): number;
  59593. /**
  59594. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59595. * This specifies what angle the shadow will use to be created.
  59596. *
  59597. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59598. */
  59599. set shadowAngle(value: number);
  59600. /**
  59601. * Gets the direction if it has been set.
  59602. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59603. */
  59604. get direction(): Vector3;
  59605. /**
  59606. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59607. */
  59608. set direction(value: Vector3);
  59609. /**
  59610. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59611. * A PointLight emits the light in every direction.
  59612. * It can cast shadows.
  59613. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59614. * ```javascript
  59615. * var pointLight = new PointLight("pl", camera.position, scene);
  59616. * ```
  59617. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59618. * @param name The light friendly name
  59619. * @param position The position of the point light in the scene
  59620. * @param scene The scene the lights belongs to
  59621. */
  59622. constructor(name: string, position: Vector3, scene: Scene);
  59623. /**
  59624. * Returns the string "PointLight"
  59625. * @returns the class name
  59626. */
  59627. getClassName(): string;
  59628. /**
  59629. * Returns the integer 0.
  59630. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59631. */
  59632. getTypeID(): number;
  59633. /**
  59634. * Specifies wether or not the shadowmap should be a cube texture.
  59635. * @returns true if the shadowmap needs to be a cube texture.
  59636. */
  59637. needCube(): boolean;
  59638. /**
  59639. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59640. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59641. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59642. */
  59643. getShadowDirection(faceIndex?: number): Vector3;
  59644. /**
  59645. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59646. * - fov = PI / 2
  59647. * - aspect ratio : 1.0
  59648. * - z-near and far equal to the active camera minZ and maxZ.
  59649. * Returns the PointLight.
  59650. */
  59651. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59652. protected _buildUniformLayout(): void;
  59653. /**
  59654. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59655. * @param effect The effect to update
  59656. * @param lightIndex The index of the light in the effect to update
  59657. * @returns The point light
  59658. */
  59659. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59660. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59661. /**
  59662. * Prepares the list of defines specific to the light type.
  59663. * @param defines the list of defines
  59664. * @param lightIndex defines the index of the light for the effect
  59665. */
  59666. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * Header information of HDR texture files.
  59672. */
  59673. export interface HDRInfo {
  59674. /**
  59675. * The height of the texture in pixels.
  59676. */
  59677. height: number;
  59678. /**
  59679. * The width of the texture in pixels.
  59680. */
  59681. width: number;
  59682. /**
  59683. * The index of the beginning of the data in the binary file.
  59684. */
  59685. dataPosition: number;
  59686. }
  59687. /**
  59688. * This groups tools to convert HDR texture to native colors array.
  59689. */
  59690. export class HDRTools {
  59691. private static Ldexp;
  59692. private static Rgbe2float;
  59693. private static readStringLine;
  59694. /**
  59695. * Reads header information from an RGBE texture stored in a native array.
  59696. * More information on this format are available here:
  59697. * https://en.wikipedia.org/wiki/RGBE_image_format
  59698. *
  59699. * @param uint8array The binary file stored in native array.
  59700. * @return The header information.
  59701. */
  59702. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59703. /**
  59704. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59705. * This RGBE texture needs to store the information as a panorama.
  59706. *
  59707. * More information on this format are available here:
  59708. * https://en.wikipedia.org/wiki/RGBE_image_format
  59709. *
  59710. * @param buffer The binary file stored in an array buffer.
  59711. * @param size The expected size of the extracted cubemap.
  59712. * @return The Cube Map information.
  59713. */
  59714. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59715. /**
  59716. * Returns the pixels data extracted from an RGBE texture.
  59717. * This pixels will be stored left to right up to down in the R G B order in one array.
  59718. *
  59719. * More information on this format are available here:
  59720. * https://en.wikipedia.org/wiki/RGBE_image_format
  59721. *
  59722. * @param uint8array The binary file stored in an array buffer.
  59723. * @param hdrInfo The header information of the file.
  59724. * @return The pixels data in RGB right to left up to down order.
  59725. */
  59726. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59727. private static RGBE_ReadPixels_RLE;
  59728. private static RGBE_ReadPixels_NOT_RLE;
  59729. }
  59730. }
  59731. declare module BABYLON {
  59732. /**
  59733. * Effect Render Options
  59734. */
  59735. export interface IEffectRendererOptions {
  59736. /**
  59737. * Defines the vertices positions.
  59738. */
  59739. positions?: number[];
  59740. /**
  59741. * Defines the indices.
  59742. */
  59743. indices?: number[];
  59744. }
  59745. /**
  59746. * Helper class to render one or more effects.
  59747. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59748. */
  59749. export class EffectRenderer {
  59750. private engine;
  59751. private static _DefaultOptions;
  59752. private _vertexBuffers;
  59753. private _indexBuffer;
  59754. private _fullscreenViewport;
  59755. /**
  59756. * Creates an effect renderer
  59757. * @param engine the engine to use for rendering
  59758. * @param options defines the options of the effect renderer
  59759. */
  59760. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59761. /**
  59762. * Sets the current viewport in normalized coordinates 0-1
  59763. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59764. */
  59765. setViewport(viewport?: Viewport): void;
  59766. /**
  59767. * Binds the embedded attributes buffer to the effect.
  59768. * @param effect Defines the effect to bind the attributes for
  59769. */
  59770. bindBuffers(effect: Effect): void;
  59771. /**
  59772. * Sets the current effect wrapper to use during draw.
  59773. * The effect needs to be ready before calling this api.
  59774. * This also sets the default full screen position attribute.
  59775. * @param effectWrapper Defines the effect to draw with
  59776. */
  59777. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59778. /**
  59779. * Restores engine states
  59780. */
  59781. restoreStates(): void;
  59782. /**
  59783. * Draws a full screen quad.
  59784. */
  59785. draw(): void;
  59786. private isRenderTargetTexture;
  59787. /**
  59788. * renders one or more effects to a specified texture
  59789. * @param effectWrapper the effect to renderer
  59790. * @param outputTexture texture to draw to, if null it will render to the screen.
  59791. */
  59792. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59793. /**
  59794. * Disposes of the effect renderer
  59795. */
  59796. dispose(): void;
  59797. }
  59798. /**
  59799. * Options to create an EffectWrapper
  59800. */
  59801. interface EffectWrapperCreationOptions {
  59802. /**
  59803. * Engine to use to create the effect
  59804. */
  59805. engine: ThinEngine;
  59806. /**
  59807. * Fragment shader for the effect
  59808. */
  59809. fragmentShader: string;
  59810. /**
  59811. * Use the shader store instead of direct source code
  59812. */
  59813. useShaderStore?: boolean;
  59814. /**
  59815. * Vertex shader for the effect
  59816. */
  59817. vertexShader?: string;
  59818. /**
  59819. * Attributes to use in the shader
  59820. */
  59821. attributeNames?: Array<string>;
  59822. /**
  59823. * Uniforms to use in the shader
  59824. */
  59825. uniformNames?: Array<string>;
  59826. /**
  59827. * Texture sampler names to use in the shader
  59828. */
  59829. samplerNames?: Array<string>;
  59830. /**
  59831. * Defines to use in the shader
  59832. */
  59833. defines?: Array<string>;
  59834. /**
  59835. * Callback when effect is compiled
  59836. */
  59837. onCompiled?: Nullable<(effect: Effect) => void>;
  59838. /**
  59839. * The friendly name of the effect displayed in Spector.
  59840. */
  59841. name?: string;
  59842. }
  59843. /**
  59844. * Wraps an effect to be used for rendering
  59845. */
  59846. export class EffectWrapper {
  59847. /**
  59848. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59849. */
  59850. onApplyObservable: Observable<{}>;
  59851. /**
  59852. * The underlying effect
  59853. */
  59854. effect: Effect;
  59855. /**
  59856. * Creates an effect to be renderer
  59857. * @param creationOptions options to create the effect
  59858. */
  59859. constructor(creationOptions: EffectWrapperCreationOptions);
  59860. /**
  59861. * Disposes of the effect wrapper
  59862. */
  59863. dispose(): void;
  59864. }
  59865. }
  59866. declare module BABYLON {
  59867. /** @hidden */
  59868. export var hdrFilteringVertexShader: {
  59869. name: string;
  59870. shader: string;
  59871. };
  59872. }
  59873. declare module BABYLON {
  59874. /** @hidden */
  59875. export var hdrFilteringPixelShader: {
  59876. name: string;
  59877. shader: string;
  59878. };
  59879. }
  59880. declare module BABYLON {
  59881. /**
  59882. * Options for texture filtering
  59883. */
  59884. interface IHDRFilteringOptions {
  59885. /**
  59886. * Scales pixel intensity for the input HDR map.
  59887. */
  59888. hdrScale?: number;
  59889. /**
  59890. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59891. */
  59892. quality?: number;
  59893. }
  59894. /**
  59895. * Filters HDR maps to get correct renderings of PBR reflections
  59896. */
  59897. export class HDRFiltering {
  59898. private _engine;
  59899. private _effectRenderer;
  59900. private _effectWrapper;
  59901. private _lodGenerationOffset;
  59902. private _lodGenerationScale;
  59903. /**
  59904. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59905. * you care about baking speed.
  59906. */
  59907. quality: number;
  59908. /**
  59909. * Scales pixel intensity for the input HDR map.
  59910. */
  59911. hdrScale: number;
  59912. /**
  59913. * Instantiates HDR filter for reflection maps
  59914. *
  59915. * @param engine Thin engine
  59916. * @param options Options
  59917. */
  59918. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59919. private _createRenderTarget;
  59920. private _prefilterInternal;
  59921. private _createEffect;
  59922. /**
  59923. * Get a value indicating if the filter is ready to be used
  59924. * @param texture Texture to filter
  59925. * @returns true if the filter is ready
  59926. */
  59927. isReady(texture: BaseTexture): boolean;
  59928. /**
  59929. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59930. * Prefiltering will be invoked at the end of next rendering pass.
  59931. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59932. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59933. * @param texture Texture to filter
  59934. * @param onFinished Callback when filtering is done
  59935. * @return Promise called when prefiltering is done
  59936. */
  59937. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59938. }
  59939. }
  59940. declare module BABYLON {
  59941. /**
  59942. * This represents a texture coming from an HDR input.
  59943. *
  59944. * The only supported format is currently panorama picture stored in RGBE format.
  59945. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59946. */
  59947. export class HDRCubeTexture extends BaseTexture {
  59948. private static _facesMapping;
  59949. private _generateHarmonics;
  59950. private _noMipmap;
  59951. private _prefilterOnLoad;
  59952. private _textureMatrix;
  59953. private _size;
  59954. private _onLoad;
  59955. private _onError;
  59956. /**
  59957. * The texture URL.
  59958. */
  59959. url: string;
  59960. /**
  59961. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59962. */
  59963. coordinatesMode: number;
  59964. protected _isBlocking: boolean;
  59965. /**
  59966. * Sets wether or not the texture is blocking during loading.
  59967. */
  59968. set isBlocking(value: boolean);
  59969. /**
  59970. * Gets wether or not the texture is blocking during loading.
  59971. */
  59972. get isBlocking(): boolean;
  59973. protected _rotationY: number;
  59974. /**
  59975. * Sets texture matrix rotation angle around Y axis in radians.
  59976. */
  59977. set rotationY(value: number);
  59978. /**
  59979. * Gets texture matrix rotation angle around Y axis radians.
  59980. */
  59981. get rotationY(): number;
  59982. /**
  59983. * Gets or sets the center of the bounding box associated with the cube texture
  59984. * It must define where the camera used to render the texture was set
  59985. */
  59986. boundingBoxPosition: Vector3;
  59987. private _boundingBoxSize;
  59988. /**
  59989. * Gets or sets the size of the bounding box associated with the cube texture
  59990. * When defined, the cubemap will switch to local mode
  59991. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59992. * @example https://www.babylonjs-playground.com/#RNASML
  59993. */
  59994. set boundingBoxSize(value: Vector3);
  59995. get boundingBoxSize(): Vector3;
  59996. /**
  59997. * Instantiates an HDRTexture from the following parameters.
  59998. *
  59999. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60000. * @param sceneOrEngine The scene or engine the texture will be used in
  60001. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60002. * @param noMipmap Forces to not generate the mipmap if true
  60003. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60004. * @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)
  60005. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60006. */
  60007. 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>);
  60008. /**
  60009. * Get the current class name of the texture useful for serialization or dynamic coding.
  60010. * @returns "HDRCubeTexture"
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * Occurs when the file is raw .hdr file.
  60015. */
  60016. private loadTexture;
  60017. clone(): HDRCubeTexture;
  60018. delayLoad(): void;
  60019. /**
  60020. * Get the texture reflection matrix used to rotate/transform the reflection.
  60021. * @returns the reflection matrix
  60022. */
  60023. getReflectionTextureMatrix(): Matrix;
  60024. /**
  60025. * Set the texture reflection matrix used to rotate/transform the reflection.
  60026. * @param value Define the reflection matrix to set
  60027. */
  60028. setReflectionTextureMatrix(value: Matrix): void;
  60029. /**
  60030. * Parses a JSON representation of an HDR Texture in order to create the texture
  60031. * @param parsedTexture Define the JSON representation
  60032. * @param scene Define the scene the texture should be created in
  60033. * @param rootUrl Define the root url in case we need to load relative dependencies
  60034. * @returns the newly created texture after parsing
  60035. */
  60036. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60037. serialize(): any;
  60038. }
  60039. }
  60040. declare module BABYLON {
  60041. /**
  60042. * Class used to control physics engine
  60043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60044. */
  60045. export class PhysicsEngine implements IPhysicsEngine {
  60046. private _physicsPlugin;
  60047. /**
  60048. * Global value used to control the smallest number supported by the simulation
  60049. */
  60050. static Epsilon: number;
  60051. private _impostors;
  60052. private _joints;
  60053. private _subTimeStep;
  60054. /**
  60055. * Gets the gravity vector used by the simulation
  60056. */
  60057. gravity: Vector3;
  60058. /**
  60059. * Factory used to create the default physics plugin.
  60060. * @returns The default physics plugin
  60061. */
  60062. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60063. /**
  60064. * Creates a new Physics Engine
  60065. * @param gravity defines the gravity vector used by the simulation
  60066. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60067. */
  60068. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60069. /**
  60070. * Sets the gravity vector used by the simulation
  60071. * @param gravity defines the gravity vector to use
  60072. */
  60073. setGravity(gravity: Vector3): void;
  60074. /**
  60075. * Set the time step of the physics engine.
  60076. * Default is 1/60.
  60077. * To slow it down, enter 1/600 for example.
  60078. * To speed it up, 1/30
  60079. * @param newTimeStep defines the new timestep to apply to this world.
  60080. */
  60081. setTimeStep(newTimeStep?: number): void;
  60082. /**
  60083. * Get the time step of the physics engine.
  60084. * @returns the current time step
  60085. */
  60086. getTimeStep(): number;
  60087. /**
  60088. * Set the sub time step of the physics engine.
  60089. * Default is 0 meaning there is no sub steps
  60090. * To increase physics resolution precision, set a small value (like 1 ms)
  60091. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60092. */
  60093. setSubTimeStep(subTimeStep?: number): void;
  60094. /**
  60095. * Get the sub time step of the physics engine.
  60096. * @returns the current sub time step
  60097. */
  60098. getSubTimeStep(): number;
  60099. /**
  60100. * Release all resources
  60101. */
  60102. dispose(): void;
  60103. /**
  60104. * Gets the name of the current physics plugin
  60105. * @returns the name of the plugin
  60106. */
  60107. getPhysicsPluginName(): string;
  60108. /**
  60109. * Adding a new impostor for the impostor tracking.
  60110. * This will be done by the impostor itself.
  60111. * @param impostor the impostor to add
  60112. */
  60113. addImpostor(impostor: PhysicsImpostor): void;
  60114. /**
  60115. * Remove an impostor from the engine.
  60116. * This impostor and its mesh will not longer be updated by the physics engine.
  60117. * @param impostor the impostor to remove
  60118. */
  60119. removeImpostor(impostor: PhysicsImpostor): void;
  60120. /**
  60121. * Add a joint to the physics engine
  60122. * @param mainImpostor defines the main impostor to which the joint is added.
  60123. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60124. * @param joint defines the joint that will connect both impostors.
  60125. */
  60126. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60127. /**
  60128. * Removes a joint from the simulation
  60129. * @param mainImpostor defines the impostor used with the joint
  60130. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60131. * @param joint defines the joint to remove
  60132. */
  60133. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60134. /**
  60135. * Called by the scene. No need to call it.
  60136. * @param delta defines the timespam between frames
  60137. */
  60138. _step(delta: number): void;
  60139. /**
  60140. * Gets the current plugin used to run the simulation
  60141. * @returns current plugin
  60142. */
  60143. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60144. /**
  60145. * Gets the list of physic impostors
  60146. * @returns an array of PhysicsImpostor
  60147. */
  60148. getImpostors(): Array<PhysicsImpostor>;
  60149. /**
  60150. * Gets the impostor for a physics enabled object
  60151. * @param object defines the object impersonated by the impostor
  60152. * @returns the PhysicsImpostor or null if not found
  60153. */
  60154. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60155. /**
  60156. * Gets the impostor for a physics body object
  60157. * @param body defines physics body used by the impostor
  60158. * @returns the PhysicsImpostor or null if not found
  60159. */
  60160. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60161. /**
  60162. * Does a raycast in the physics world
  60163. * @param from when should the ray start?
  60164. * @param to when should the ray end?
  60165. * @returns PhysicsRaycastResult
  60166. */
  60167. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60168. }
  60169. }
  60170. declare module BABYLON {
  60171. /** @hidden */
  60172. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60173. private _useDeltaForWorldStep;
  60174. world: any;
  60175. name: string;
  60176. private _physicsMaterials;
  60177. private _fixedTimeStep;
  60178. private _cannonRaycastResult;
  60179. private _raycastResult;
  60180. private _physicsBodysToRemoveAfterStep;
  60181. private _firstFrame;
  60182. BJSCANNON: any;
  60183. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60184. setGravity(gravity: Vector3): void;
  60185. setTimeStep(timeStep: number): void;
  60186. getTimeStep(): number;
  60187. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60188. private _removeMarkedPhysicsBodiesFromWorld;
  60189. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60190. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60191. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60192. private _processChildMeshes;
  60193. removePhysicsBody(impostor: PhysicsImpostor): void;
  60194. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60195. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60196. private _addMaterial;
  60197. private _checkWithEpsilon;
  60198. private _createShape;
  60199. private _createHeightmap;
  60200. private _minus90X;
  60201. private _plus90X;
  60202. private _tmpPosition;
  60203. private _tmpDeltaPosition;
  60204. private _tmpUnityRotation;
  60205. private _updatePhysicsBodyTransformation;
  60206. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60207. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60208. isSupported(): boolean;
  60209. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60210. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60211. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60212. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60213. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60214. getBodyMass(impostor: PhysicsImpostor): number;
  60215. getBodyFriction(impostor: PhysicsImpostor): number;
  60216. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60217. getBodyRestitution(impostor: PhysicsImpostor): number;
  60218. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60219. sleepBody(impostor: PhysicsImpostor): void;
  60220. wakeUpBody(impostor: PhysicsImpostor): void;
  60221. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60222. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60223. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60224. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60225. getRadius(impostor: PhysicsImpostor): number;
  60226. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60227. dispose(): void;
  60228. private _extendNamespace;
  60229. /**
  60230. * Does a raycast in the physics world
  60231. * @param from when should the ray start?
  60232. * @param to when should the ray end?
  60233. * @returns PhysicsRaycastResult
  60234. */
  60235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /** @hidden */
  60240. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60241. private _useDeltaForWorldStep;
  60242. world: any;
  60243. name: string;
  60244. BJSOIMO: any;
  60245. private _raycastResult;
  60246. private _fixedTimeStep;
  60247. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60248. setGravity(gravity: Vector3): void;
  60249. setTimeStep(timeStep: number): void;
  60250. getTimeStep(): number;
  60251. private _tmpImpostorsArray;
  60252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60253. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60254. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60255. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60256. private _tmpPositionVector;
  60257. removePhysicsBody(impostor: PhysicsImpostor): void;
  60258. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60259. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60260. isSupported(): boolean;
  60261. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60262. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60263. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60264. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60266. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60267. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60268. getBodyMass(impostor: PhysicsImpostor): number;
  60269. getBodyFriction(impostor: PhysicsImpostor): number;
  60270. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60271. getBodyRestitution(impostor: PhysicsImpostor): number;
  60272. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60273. sleepBody(impostor: PhysicsImpostor): void;
  60274. wakeUpBody(impostor: PhysicsImpostor): void;
  60275. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60276. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60277. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60278. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60279. getRadius(impostor: PhysicsImpostor): number;
  60280. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60281. dispose(): void;
  60282. /**
  60283. * Does a raycast in the physics world
  60284. * @param from when should the ray start?
  60285. * @param to when should the ray end?
  60286. * @returns PhysicsRaycastResult
  60287. */
  60288. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60289. }
  60290. }
  60291. declare module BABYLON {
  60292. /**
  60293. * AmmoJS Physics plugin
  60294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60295. * @see https://github.com/kripken/ammo.js/
  60296. */
  60297. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60298. private _useDeltaForWorldStep;
  60299. /**
  60300. * Reference to the Ammo library
  60301. */
  60302. bjsAMMO: any;
  60303. /**
  60304. * Created ammoJS world which physics bodies are added to
  60305. */
  60306. world: any;
  60307. /**
  60308. * Name of the plugin
  60309. */
  60310. name: string;
  60311. private _timeStep;
  60312. private _fixedTimeStep;
  60313. private _maxSteps;
  60314. private _tmpQuaternion;
  60315. private _tmpAmmoTransform;
  60316. private _tmpAmmoQuaternion;
  60317. private _tmpAmmoConcreteContactResultCallback;
  60318. private _collisionConfiguration;
  60319. private _dispatcher;
  60320. private _overlappingPairCache;
  60321. private _solver;
  60322. private _softBodySolver;
  60323. private _tmpAmmoVectorA;
  60324. private _tmpAmmoVectorB;
  60325. private _tmpAmmoVectorC;
  60326. private _tmpAmmoVectorD;
  60327. private _tmpContactCallbackResult;
  60328. private _tmpAmmoVectorRCA;
  60329. private _tmpAmmoVectorRCB;
  60330. private _raycastResult;
  60331. private static readonly DISABLE_COLLISION_FLAG;
  60332. private static readonly KINEMATIC_FLAG;
  60333. private static readonly DISABLE_DEACTIVATION_FLAG;
  60334. /**
  60335. * Initializes the ammoJS plugin
  60336. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60337. * @param ammoInjection can be used to inject your own ammo reference
  60338. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60339. */
  60340. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60341. /**
  60342. * Sets the gravity of the physics world (m/(s^2))
  60343. * @param gravity Gravity to set
  60344. */
  60345. setGravity(gravity: Vector3): void;
  60346. /**
  60347. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60348. * @param timeStep timestep to use in seconds
  60349. */
  60350. setTimeStep(timeStep: number): void;
  60351. /**
  60352. * 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)
  60353. * @param fixedTimeStep fixedTimeStep to use in seconds
  60354. */
  60355. setFixedTimeStep(fixedTimeStep: number): void;
  60356. /**
  60357. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60358. * @param maxSteps the maximum number of steps by the physics engine per frame
  60359. */
  60360. setMaxSteps(maxSteps: number): void;
  60361. /**
  60362. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60363. * @returns the current timestep in seconds
  60364. */
  60365. getTimeStep(): number;
  60366. /**
  60367. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60368. */
  60369. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60370. private _isImpostorInContact;
  60371. private _isImpostorPairInContact;
  60372. private _stepSimulation;
  60373. /**
  60374. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60375. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60376. * After the step the babylon meshes are set to the position of the physics imposters
  60377. * @param delta amount of time to step forward
  60378. * @param impostors array of imposters to update before/after the step
  60379. */
  60380. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60381. /**
  60382. * Update babylon mesh to match physics world object
  60383. * @param impostor imposter to match
  60384. */
  60385. private _afterSoftStep;
  60386. /**
  60387. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60388. * @param impostor imposter to match
  60389. */
  60390. private _ropeStep;
  60391. /**
  60392. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60393. * @param impostor imposter to match
  60394. */
  60395. private _softbodyOrClothStep;
  60396. private _tmpMatrix;
  60397. /**
  60398. * Applies an impulse on the imposter
  60399. * @param impostor imposter to apply impulse to
  60400. * @param force amount of force to be applied to the imposter
  60401. * @param contactPoint the location to apply the impulse on the imposter
  60402. */
  60403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60404. /**
  60405. * Applies a force on the imposter
  60406. * @param impostor imposter to apply force
  60407. * @param force amount of force to be applied to the imposter
  60408. * @param contactPoint the location to apply the force on the imposter
  60409. */
  60410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60411. /**
  60412. * Creates a physics body using the plugin
  60413. * @param impostor the imposter to create the physics body on
  60414. */
  60415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60416. /**
  60417. * Removes the physics body from the imposter and disposes of the body's memory
  60418. * @param impostor imposter to remove the physics body from
  60419. */
  60420. removePhysicsBody(impostor: PhysicsImpostor): void;
  60421. /**
  60422. * Generates a joint
  60423. * @param impostorJoint the imposter joint to create the joint with
  60424. */
  60425. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60426. /**
  60427. * Removes a joint
  60428. * @param impostorJoint the imposter joint to remove the joint from
  60429. */
  60430. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60431. private _addMeshVerts;
  60432. /**
  60433. * Initialise the soft body vertices to match its object's (mesh) vertices
  60434. * Softbody vertices (nodes) are in world space and to match this
  60435. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60436. * @param impostor to create the softbody for
  60437. */
  60438. private _softVertexData;
  60439. /**
  60440. * Create an impostor's soft body
  60441. * @param impostor to create the softbody for
  60442. */
  60443. private _createSoftbody;
  60444. /**
  60445. * Create cloth for an impostor
  60446. * @param impostor to create the softbody for
  60447. */
  60448. private _createCloth;
  60449. /**
  60450. * Create rope for an impostor
  60451. * @param impostor to create the softbody for
  60452. */
  60453. private _createRope;
  60454. /**
  60455. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60456. * @param impostor to create the custom physics shape for
  60457. */
  60458. private _createCustom;
  60459. private _addHullVerts;
  60460. private _createShape;
  60461. /**
  60462. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60463. * @param impostor imposter containing the physics body and babylon object
  60464. */
  60465. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60466. /**
  60467. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60468. * @param impostor imposter containing the physics body and babylon object
  60469. * @param newPosition new position
  60470. * @param newRotation new rotation
  60471. */
  60472. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60473. /**
  60474. * If this plugin is supported
  60475. * @returns true if its supported
  60476. */
  60477. isSupported(): boolean;
  60478. /**
  60479. * Sets the linear velocity of the physics body
  60480. * @param impostor imposter to set the velocity on
  60481. * @param velocity velocity to set
  60482. */
  60483. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60484. /**
  60485. * Sets the angular velocity of the physics body
  60486. * @param impostor imposter to set the velocity on
  60487. * @param velocity velocity to set
  60488. */
  60489. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60490. /**
  60491. * gets the linear velocity
  60492. * @param impostor imposter to get linear velocity from
  60493. * @returns linear velocity
  60494. */
  60495. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60496. /**
  60497. * gets the angular velocity
  60498. * @param impostor imposter to get angular velocity from
  60499. * @returns angular velocity
  60500. */
  60501. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60502. /**
  60503. * Sets the mass of physics body
  60504. * @param impostor imposter to set the mass on
  60505. * @param mass mass to set
  60506. */
  60507. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60508. /**
  60509. * Gets the mass of the physics body
  60510. * @param impostor imposter to get the mass from
  60511. * @returns mass
  60512. */
  60513. getBodyMass(impostor: PhysicsImpostor): number;
  60514. /**
  60515. * Gets friction of the impostor
  60516. * @param impostor impostor to get friction from
  60517. * @returns friction value
  60518. */
  60519. getBodyFriction(impostor: PhysicsImpostor): number;
  60520. /**
  60521. * Sets friction of the impostor
  60522. * @param impostor impostor to set friction on
  60523. * @param friction friction value
  60524. */
  60525. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60526. /**
  60527. * Gets restitution of the impostor
  60528. * @param impostor impostor to get restitution from
  60529. * @returns restitution value
  60530. */
  60531. getBodyRestitution(impostor: PhysicsImpostor): number;
  60532. /**
  60533. * Sets resitution of the impostor
  60534. * @param impostor impostor to set resitution on
  60535. * @param restitution resitution value
  60536. */
  60537. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60538. /**
  60539. * Gets pressure inside the impostor
  60540. * @param impostor impostor to get pressure from
  60541. * @returns pressure value
  60542. */
  60543. getBodyPressure(impostor: PhysicsImpostor): number;
  60544. /**
  60545. * Sets pressure inside a soft body impostor
  60546. * Cloth and rope must remain 0 pressure
  60547. * @param impostor impostor to set pressure on
  60548. * @param pressure pressure value
  60549. */
  60550. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60551. /**
  60552. * Gets stiffness of the impostor
  60553. * @param impostor impostor to get stiffness from
  60554. * @returns pressure value
  60555. */
  60556. getBodyStiffness(impostor: PhysicsImpostor): number;
  60557. /**
  60558. * Sets stiffness of the impostor
  60559. * @param impostor impostor to set stiffness on
  60560. * @param stiffness stiffness value from 0 to 1
  60561. */
  60562. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60563. /**
  60564. * Gets velocityIterations of the impostor
  60565. * @param impostor impostor to get velocity iterations from
  60566. * @returns velocityIterations value
  60567. */
  60568. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60569. /**
  60570. * Sets velocityIterations of the impostor
  60571. * @param impostor impostor to set velocity iterations on
  60572. * @param velocityIterations velocityIterations value
  60573. */
  60574. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60575. /**
  60576. * Gets positionIterations of the impostor
  60577. * @param impostor impostor to get position iterations from
  60578. * @returns positionIterations value
  60579. */
  60580. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60581. /**
  60582. * Sets positionIterations of the impostor
  60583. * @param impostor impostor to set position on
  60584. * @param positionIterations positionIterations value
  60585. */
  60586. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60587. /**
  60588. * Append an anchor to a cloth object
  60589. * @param impostor is the cloth impostor to add anchor to
  60590. * @param otherImpostor is the rigid impostor to anchor to
  60591. * @param width ratio across width from 0 to 1
  60592. * @param height ratio up height from 0 to 1
  60593. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60594. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60595. */
  60596. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60597. /**
  60598. * Append an hook to a rope object
  60599. * @param impostor is the rope impostor to add hook to
  60600. * @param otherImpostor is the rigid impostor to hook to
  60601. * @param length ratio along the rope from 0 to 1
  60602. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60603. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60604. */
  60605. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60606. /**
  60607. * Sleeps the physics body and stops it from being active
  60608. * @param impostor impostor to sleep
  60609. */
  60610. sleepBody(impostor: PhysicsImpostor): void;
  60611. /**
  60612. * Activates the physics body
  60613. * @param impostor impostor to activate
  60614. */
  60615. wakeUpBody(impostor: PhysicsImpostor): void;
  60616. /**
  60617. * Updates the distance parameters of the joint
  60618. * @param joint joint to update
  60619. * @param maxDistance maximum distance of the joint
  60620. * @param minDistance minimum distance of the joint
  60621. */
  60622. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60623. /**
  60624. * Sets a motor on the joint
  60625. * @param joint joint to set motor on
  60626. * @param speed speed of the motor
  60627. * @param maxForce maximum force of the motor
  60628. * @param motorIndex index of the motor
  60629. */
  60630. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60631. /**
  60632. * Sets the motors limit
  60633. * @param joint joint to set limit on
  60634. * @param upperLimit upper limit
  60635. * @param lowerLimit lower limit
  60636. */
  60637. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60638. /**
  60639. * Syncs the position and rotation of a mesh with the impostor
  60640. * @param mesh mesh to sync
  60641. * @param impostor impostor to update the mesh with
  60642. */
  60643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60644. /**
  60645. * Gets the radius of the impostor
  60646. * @param impostor impostor to get radius from
  60647. * @returns the radius
  60648. */
  60649. getRadius(impostor: PhysicsImpostor): number;
  60650. /**
  60651. * Gets the box size of the impostor
  60652. * @param impostor impostor to get box size from
  60653. * @param result the resulting box size
  60654. */
  60655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60656. /**
  60657. * Disposes of the impostor
  60658. */
  60659. dispose(): void;
  60660. /**
  60661. * Does a raycast in the physics world
  60662. * @param from when should the ray start?
  60663. * @param to when should the ray end?
  60664. * @returns PhysicsRaycastResult
  60665. */
  60666. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60667. }
  60668. }
  60669. declare module BABYLON {
  60670. interface AbstractScene {
  60671. /**
  60672. * The list of reflection probes added to the scene
  60673. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60674. */
  60675. reflectionProbes: Array<ReflectionProbe>;
  60676. /**
  60677. * Removes the given reflection probe from this scene.
  60678. * @param toRemove The reflection probe to remove
  60679. * @returns The index of the removed reflection probe
  60680. */
  60681. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60682. /**
  60683. * Adds the given reflection probe to this scene.
  60684. * @param newReflectionProbe The reflection probe to add
  60685. */
  60686. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60687. }
  60688. /**
  60689. * Class used to generate realtime reflection / refraction cube textures
  60690. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60691. */
  60692. export class ReflectionProbe {
  60693. /** defines the name of the probe */
  60694. name: string;
  60695. private _scene;
  60696. private _renderTargetTexture;
  60697. private _projectionMatrix;
  60698. private _viewMatrix;
  60699. private _target;
  60700. private _add;
  60701. private _attachedMesh;
  60702. private _invertYAxis;
  60703. /** Gets or sets probe position (center of the cube map) */
  60704. position: Vector3;
  60705. /**
  60706. * Creates a new reflection probe
  60707. * @param name defines the name of the probe
  60708. * @param size defines the texture resolution (for each face)
  60709. * @param scene defines the hosting scene
  60710. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60711. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60712. */
  60713. constructor(
  60714. /** defines the name of the probe */
  60715. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60716. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60717. get samples(): number;
  60718. set samples(value: number);
  60719. /** Gets or sets the refresh rate to use (on every frame by default) */
  60720. get refreshRate(): number;
  60721. set refreshRate(value: number);
  60722. /**
  60723. * Gets the hosting scene
  60724. * @returns a Scene
  60725. */
  60726. getScene(): Scene;
  60727. /** Gets the internal CubeTexture used to render to */
  60728. get cubeTexture(): RenderTargetTexture;
  60729. /** Gets the list of meshes to render */
  60730. get renderList(): Nullable<AbstractMesh[]>;
  60731. /**
  60732. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60733. * @param mesh defines the mesh to attach to
  60734. */
  60735. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60736. /**
  60737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60738. * @param renderingGroupId The rendering group id corresponding to its index
  60739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60740. */
  60741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60742. /**
  60743. * Clean all associated resources
  60744. */
  60745. dispose(): void;
  60746. /**
  60747. * Converts the reflection probe information to a readable string for debug purpose.
  60748. * @param fullDetails Supports for multiple levels of logging within scene loading
  60749. * @returns the human readable reflection probe info
  60750. */
  60751. toString(fullDetails?: boolean): string;
  60752. /**
  60753. * Get the class name of the relfection probe.
  60754. * @returns "ReflectionProbe"
  60755. */
  60756. getClassName(): string;
  60757. /**
  60758. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60759. * @returns The JSON representation of the texture
  60760. */
  60761. serialize(): any;
  60762. /**
  60763. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60764. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60765. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60766. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60767. * @returns The parsed reflection probe if successful
  60768. */
  60769. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60770. }
  60771. }
  60772. declare module BABYLON {
  60773. /** @hidden */
  60774. export var _BabylonLoaderRegistered: boolean;
  60775. /**
  60776. * Helps setting up some configuration for the babylon file loader.
  60777. */
  60778. export class BabylonFileLoaderConfiguration {
  60779. /**
  60780. * The loader does not allow injecting custom physix engine into the plugins.
  60781. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60782. * So you could set this variable to your engine import to make it work.
  60783. */
  60784. static LoaderInjectedPhysicsEngine: any;
  60785. }
  60786. }
  60787. declare module BABYLON {
  60788. /**
  60789. * The Physically based simple base material of BJS.
  60790. *
  60791. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60792. * It is used as the base class for both the specGloss and metalRough conventions.
  60793. */
  60794. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60795. /**
  60796. * Number of Simultaneous lights allowed on the material.
  60797. */
  60798. maxSimultaneousLights: number;
  60799. /**
  60800. * If sets to true, disables all the lights affecting the material.
  60801. */
  60802. disableLighting: boolean;
  60803. /**
  60804. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60805. */
  60806. environmentTexture: BaseTexture;
  60807. /**
  60808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60809. */
  60810. invertNormalMapX: boolean;
  60811. /**
  60812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60813. */
  60814. invertNormalMapY: boolean;
  60815. /**
  60816. * Normal map used in the model.
  60817. */
  60818. normalTexture: BaseTexture;
  60819. /**
  60820. * Emissivie color used to self-illuminate the model.
  60821. */
  60822. emissiveColor: Color3;
  60823. /**
  60824. * Emissivie texture used to self-illuminate the model.
  60825. */
  60826. emissiveTexture: BaseTexture;
  60827. /**
  60828. * Occlusion Channel Strenght.
  60829. */
  60830. occlusionStrength: number;
  60831. /**
  60832. * Occlusion Texture of the material (adding extra occlusion effects).
  60833. */
  60834. occlusionTexture: BaseTexture;
  60835. /**
  60836. * Defines the alpha limits in alpha test mode.
  60837. */
  60838. alphaCutOff: number;
  60839. /**
  60840. * Gets the current double sided mode.
  60841. */
  60842. get doubleSided(): boolean;
  60843. /**
  60844. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60845. */
  60846. set doubleSided(value: boolean);
  60847. /**
  60848. * Stores the pre-calculated light information of a mesh in a texture.
  60849. */
  60850. lightmapTexture: BaseTexture;
  60851. /**
  60852. * If true, the light map contains occlusion information instead of lighting info.
  60853. */
  60854. useLightmapAsShadowmap: boolean;
  60855. /**
  60856. * Instantiates a new PBRMaterial instance.
  60857. *
  60858. * @param name The material name
  60859. * @param scene The scene the material will be use in.
  60860. */
  60861. constructor(name: string, scene: Scene);
  60862. getClassName(): string;
  60863. }
  60864. }
  60865. declare module BABYLON {
  60866. /**
  60867. * The PBR material of BJS following the metal roughness convention.
  60868. *
  60869. * This fits to the PBR convention in the GLTF definition:
  60870. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60871. */
  60872. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60873. /**
  60874. * The base color has two different interpretations depending on the value of metalness.
  60875. * When the material is a metal, the base color is the specific measured reflectance value
  60876. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60877. * of the material.
  60878. */
  60879. baseColor: Color3;
  60880. /**
  60881. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60882. * well as opacity information in the alpha channel.
  60883. */
  60884. baseTexture: BaseTexture;
  60885. /**
  60886. * Specifies the metallic scalar value of the material.
  60887. * Can also be used to scale the metalness values of the metallic texture.
  60888. */
  60889. metallic: number;
  60890. /**
  60891. * Specifies the roughness scalar value of the material.
  60892. * Can also be used to scale the roughness values of the metallic texture.
  60893. */
  60894. roughness: number;
  60895. /**
  60896. * Texture containing both the metallic value in the B channel and the
  60897. * roughness value in the G channel to keep better precision.
  60898. */
  60899. metallicRoughnessTexture: BaseTexture;
  60900. /**
  60901. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60902. *
  60903. * @param name The material name
  60904. * @param scene The scene the material will be use in.
  60905. */
  60906. constructor(name: string, scene: Scene);
  60907. /**
  60908. * Return the currrent class name of the material.
  60909. */
  60910. getClassName(): string;
  60911. /**
  60912. * Makes a duplicate of the current material.
  60913. * @param name - name to use for the new material.
  60914. */
  60915. clone(name: string): PBRMetallicRoughnessMaterial;
  60916. /**
  60917. * Serialize the material to a parsable JSON object.
  60918. */
  60919. serialize(): any;
  60920. /**
  60921. * Parses a JSON object correponding to the serialize function.
  60922. */
  60923. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60924. }
  60925. }
  60926. declare module BABYLON {
  60927. /**
  60928. * The PBR material of BJS following the specular glossiness convention.
  60929. *
  60930. * This fits to the PBR convention in the GLTF definition:
  60931. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60932. */
  60933. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60934. /**
  60935. * Specifies the diffuse color of the material.
  60936. */
  60937. diffuseColor: Color3;
  60938. /**
  60939. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60940. * channel.
  60941. */
  60942. diffuseTexture: BaseTexture;
  60943. /**
  60944. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60945. */
  60946. specularColor: Color3;
  60947. /**
  60948. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60949. */
  60950. glossiness: number;
  60951. /**
  60952. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60953. */
  60954. specularGlossinessTexture: BaseTexture;
  60955. /**
  60956. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60957. *
  60958. * @param name The material name
  60959. * @param scene The scene the material will be use in.
  60960. */
  60961. constructor(name: string, scene: Scene);
  60962. /**
  60963. * Return the currrent class name of the material.
  60964. */
  60965. getClassName(): string;
  60966. /**
  60967. * Makes a duplicate of the current material.
  60968. * @param name - name to use for the new material.
  60969. */
  60970. clone(name: string): PBRSpecularGlossinessMaterial;
  60971. /**
  60972. * Serialize the material to a parsable JSON object.
  60973. */
  60974. serialize(): any;
  60975. /**
  60976. * Parses a JSON object correponding to the serialize function.
  60977. */
  60978. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60979. }
  60980. }
  60981. declare module BABYLON {
  60982. /**
  60983. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60984. * It can help converting any input color in a desired output one. This can then be used to create effects
  60985. * from sepia, black and white to sixties or futuristic rendering...
  60986. *
  60987. * The only supported format is currently 3dl.
  60988. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60989. */
  60990. export class ColorGradingTexture extends BaseTexture {
  60991. /**
  60992. * The texture URL.
  60993. */
  60994. url: string;
  60995. /**
  60996. * Empty line regex stored for GC.
  60997. */
  60998. private static _noneEmptyLineRegex;
  60999. private _textureMatrix;
  61000. private _onLoad;
  61001. /**
  61002. * Instantiates a ColorGradingTexture from the following parameters.
  61003. *
  61004. * @param url The location of the color gradind data (currently only supporting 3dl)
  61005. * @param sceneOrEngine The scene or engine the texture will be used in
  61006. * @param onLoad defines a callback triggered when the texture has been loaded
  61007. */
  61008. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61009. /**
  61010. * Fires the onload event from the constructor if requested.
  61011. */
  61012. private _triggerOnLoad;
  61013. /**
  61014. * Returns the texture matrix used in most of the material.
  61015. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61016. */
  61017. getTextureMatrix(): Matrix;
  61018. /**
  61019. * Occurs when the file being loaded is a .3dl LUT file.
  61020. */
  61021. private load3dlTexture;
  61022. /**
  61023. * Starts the loading process of the texture.
  61024. */
  61025. private loadTexture;
  61026. /**
  61027. * Clones the color gradind texture.
  61028. */
  61029. clone(): ColorGradingTexture;
  61030. /**
  61031. * Called during delayed load for textures.
  61032. */
  61033. delayLoad(): void;
  61034. /**
  61035. * Parses a color grading texture serialized by Babylon.
  61036. * @param parsedTexture The texture information being parsedTexture
  61037. * @param scene The scene to load the texture in
  61038. * @param rootUrl The root url of the data assets to load
  61039. * @return A color gradind texture
  61040. */
  61041. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61042. /**
  61043. * Serializes the LUT texture to json format.
  61044. */
  61045. serialize(): any;
  61046. }
  61047. }
  61048. declare module BABYLON {
  61049. /**
  61050. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61051. */
  61052. export class EquiRectangularCubeTexture extends BaseTexture {
  61053. /** The six faces of the cube. */
  61054. private static _FacesMapping;
  61055. private _noMipmap;
  61056. private _onLoad;
  61057. private _onError;
  61058. /** The size of the cubemap. */
  61059. private _size;
  61060. /** The buffer of the image. */
  61061. private _buffer;
  61062. /** The width of the input image. */
  61063. private _width;
  61064. /** The height of the input image. */
  61065. private _height;
  61066. /** The URL to the image. */
  61067. url: string;
  61068. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  61069. coordinatesMode: number;
  61070. /**
  61071. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61072. * @param url The location of the image
  61073. * @param scene The scene the texture will be used in
  61074. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61075. * @param noMipmap Forces to not generate the mipmap if true
  61076. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61077. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61078. * @param onLoad — defines a callback called when texture is loaded
  61079. * @param onError — defines a callback called if there is an error
  61080. */
  61081. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61082. /**
  61083. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61084. */
  61085. private loadImage;
  61086. /**
  61087. * Convert the image buffer into a cubemap and create a CubeTexture.
  61088. */
  61089. private loadTexture;
  61090. /**
  61091. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61092. * @param buffer The ArrayBuffer that should be converted.
  61093. * @returns The buffer as Float32Array.
  61094. */
  61095. private getFloat32ArrayFromArrayBuffer;
  61096. /**
  61097. * Get the current class name of the texture useful for serialization or dynamic coding.
  61098. * @returns "EquiRectangularCubeTexture"
  61099. */
  61100. getClassName(): string;
  61101. /**
  61102. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61103. * @returns A clone of the current EquiRectangularCubeTexture.
  61104. */
  61105. clone(): EquiRectangularCubeTexture;
  61106. }
  61107. }
  61108. declare module BABYLON {
  61109. /**
  61110. * Defines the options related to the creation of an HtmlElementTexture
  61111. */
  61112. export interface IHtmlElementTextureOptions {
  61113. /**
  61114. * Defines wether mip maps should be created or not.
  61115. */
  61116. generateMipMaps?: boolean;
  61117. /**
  61118. * Defines the sampling mode of the texture.
  61119. */
  61120. samplingMode?: number;
  61121. /**
  61122. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61123. */
  61124. engine: Nullable<ThinEngine>;
  61125. /**
  61126. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61127. */
  61128. scene: Nullable<Scene>;
  61129. }
  61130. /**
  61131. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61132. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61133. * is automatically managed.
  61134. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61135. * in your application.
  61136. *
  61137. * As the update is not automatic, you need to call them manually.
  61138. */
  61139. export class HtmlElementTexture extends BaseTexture {
  61140. /**
  61141. * The texture URL.
  61142. */
  61143. element: HTMLVideoElement | HTMLCanvasElement;
  61144. private static readonly DefaultOptions;
  61145. private _textureMatrix;
  61146. private _isVideo;
  61147. private _generateMipMaps;
  61148. private _samplingMode;
  61149. /**
  61150. * Instantiates a HtmlElementTexture from the following parameters.
  61151. *
  61152. * @param name Defines the name of the texture
  61153. * @param element Defines the video or canvas the texture is filled with
  61154. * @param options Defines the other none mandatory texture creation options
  61155. */
  61156. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61157. private _createInternalTexture;
  61158. /**
  61159. * Returns the texture matrix used in most of the material.
  61160. */
  61161. getTextureMatrix(): Matrix;
  61162. /**
  61163. * Updates the content of the texture.
  61164. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61165. */
  61166. update(invertY?: Nullable<boolean>): void;
  61167. }
  61168. }
  61169. declare module BABYLON {
  61170. /**
  61171. * Based on jsTGALoader - Javascript loader for TGA file
  61172. * By Vincent Thibault
  61173. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61174. */
  61175. export class TGATools {
  61176. private static _TYPE_INDEXED;
  61177. private static _TYPE_RGB;
  61178. private static _TYPE_GREY;
  61179. private static _TYPE_RLE_INDEXED;
  61180. private static _TYPE_RLE_RGB;
  61181. private static _TYPE_RLE_GREY;
  61182. private static _ORIGIN_MASK;
  61183. private static _ORIGIN_SHIFT;
  61184. private static _ORIGIN_BL;
  61185. private static _ORIGIN_BR;
  61186. private static _ORIGIN_UL;
  61187. private static _ORIGIN_UR;
  61188. /**
  61189. * Gets the header of a TGA file
  61190. * @param data defines the TGA data
  61191. * @returns the header
  61192. */
  61193. static GetTGAHeader(data: Uint8Array): any;
  61194. /**
  61195. * Uploads TGA content to a Babylon Texture
  61196. * @hidden
  61197. */
  61198. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61199. /** @hidden */
  61200. 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;
  61201. /** @hidden */
  61202. 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;
  61203. /** @hidden */
  61204. 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;
  61205. /** @hidden */
  61206. 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;
  61207. /** @hidden */
  61208. 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;
  61209. /** @hidden */
  61210. 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;
  61211. }
  61212. }
  61213. declare module BABYLON {
  61214. /**
  61215. * Implementation of the TGA Texture Loader.
  61216. * @hidden
  61217. */
  61218. export class _TGATextureLoader implements IInternalTextureLoader {
  61219. /**
  61220. * Defines wether the loader supports cascade loading the different faces.
  61221. */
  61222. readonly supportCascades: boolean;
  61223. /**
  61224. * This returns if the loader support the current file information.
  61225. * @param extension defines the file extension of the file being loaded
  61226. * @returns true if the loader can load the specified file
  61227. */
  61228. canLoad(extension: string): boolean;
  61229. /**
  61230. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61231. * @param data contains the texture data
  61232. * @param texture defines the BabylonJS internal texture
  61233. * @param createPolynomials will be true if polynomials have been requested
  61234. * @param onLoad defines the callback to trigger once the texture is ready
  61235. * @param onError defines the callback to trigger in case of error
  61236. */
  61237. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61238. /**
  61239. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61240. * @param data contains the texture data
  61241. * @param texture defines the BabylonJS internal texture
  61242. * @param callback defines the method to call once ready to upload
  61243. */
  61244. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61245. }
  61246. }
  61247. declare module BABYLON {
  61248. /**
  61249. * Info about the .basis files
  61250. */
  61251. class BasisFileInfo {
  61252. /**
  61253. * If the file has alpha
  61254. */
  61255. hasAlpha: boolean;
  61256. /**
  61257. * Info about each image of the basis file
  61258. */
  61259. images: Array<{
  61260. levels: Array<{
  61261. width: number;
  61262. height: number;
  61263. transcodedPixels: ArrayBufferView;
  61264. }>;
  61265. }>;
  61266. }
  61267. /**
  61268. * Result of transcoding a basis file
  61269. */
  61270. class TranscodeResult {
  61271. /**
  61272. * Info about the .basis file
  61273. */
  61274. fileInfo: BasisFileInfo;
  61275. /**
  61276. * Format to use when loading the file
  61277. */
  61278. format: number;
  61279. }
  61280. /**
  61281. * Configuration options for the Basis transcoder
  61282. */
  61283. export class BasisTranscodeConfiguration {
  61284. /**
  61285. * Supported compression formats used to determine the supported output format of the transcoder
  61286. */
  61287. supportedCompressionFormats?: {
  61288. /**
  61289. * etc1 compression format
  61290. */
  61291. etc1?: boolean;
  61292. /**
  61293. * s3tc compression format
  61294. */
  61295. s3tc?: boolean;
  61296. /**
  61297. * pvrtc compression format
  61298. */
  61299. pvrtc?: boolean;
  61300. /**
  61301. * etc2 compression format
  61302. */
  61303. etc2?: boolean;
  61304. };
  61305. /**
  61306. * If mipmap levels should be loaded for transcoded images (Default: true)
  61307. */
  61308. loadMipmapLevels?: boolean;
  61309. /**
  61310. * Index of a single image to load (Default: all images)
  61311. */
  61312. loadSingleImage?: number;
  61313. }
  61314. /**
  61315. * Used to load .Basis files
  61316. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61317. */
  61318. export class BasisTools {
  61319. private static _IgnoreSupportedFormats;
  61320. /**
  61321. * URL to use when loading the basis transcoder
  61322. */
  61323. static JSModuleURL: string;
  61324. /**
  61325. * URL to use when loading the wasm module for the transcoder
  61326. */
  61327. static WasmModuleURL: string;
  61328. /**
  61329. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61330. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61331. * @returns internal format corresponding to the Basis format
  61332. */
  61333. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61334. private static _WorkerPromise;
  61335. private static _Worker;
  61336. private static _actionId;
  61337. private static _CreateWorkerAsync;
  61338. /**
  61339. * Transcodes a loaded image file to compressed pixel data
  61340. * @param data image data to transcode
  61341. * @param config configuration options for the transcoding
  61342. * @returns a promise resulting in the transcoded image
  61343. */
  61344. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61345. /**
  61346. * Loads a texture from the transcode result
  61347. * @param texture texture load to
  61348. * @param transcodeResult the result of transcoding the basis file to load from
  61349. */
  61350. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61351. }
  61352. }
  61353. declare module BABYLON {
  61354. /**
  61355. * Loader for .basis file format
  61356. */
  61357. export class _BasisTextureLoader implements IInternalTextureLoader {
  61358. /**
  61359. * Defines whether the loader supports cascade loading the different faces.
  61360. */
  61361. readonly supportCascades: boolean;
  61362. /**
  61363. * This returns if the loader support the current file information.
  61364. * @param extension defines the file extension of the file being loaded
  61365. * @returns true if the loader can load the specified file
  61366. */
  61367. canLoad(extension: string): boolean;
  61368. /**
  61369. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61370. * @param data contains the texture data
  61371. * @param texture defines the BabylonJS internal texture
  61372. * @param createPolynomials will be true if polynomials have been requested
  61373. * @param onLoad defines the callback to trigger once the texture is ready
  61374. * @param onError defines the callback to trigger in case of error
  61375. */
  61376. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61377. /**
  61378. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61379. * @param data contains the texture data
  61380. * @param texture defines the BabylonJS internal texture
  61381. * @param callback defines the method to call once ready to upload
  61382. */
  61383. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61384. }
  61385. }
  61386. declare module BABYLON {
  61387. /**
  61388. * Defines the basic options interface of a TexturePacker Frame
  61389. */
  61390. export interface ITexturePackerFrame {
  61391. /**
  61392. * The frame ID
  61393. */
  61394. id: number;
  61395. /**
  61396. * The frames Scale
  61397. */
  61398. scale: Vector2;
  61399. /**
  61400. * The Frames offset
  61401. */
  61402. offset: Vector2;
  61403. }
  61404. /**
  61405. * This is a support class for frame Data on texture packer sets.
  61406. */
  61407. export class TexturePackerFrame implements ITexturePackerFrame {
  61408. /**
  61409. * The frame ID
  61410. */
  61411. id: number;
  61412. /**
  61413. * The frames Scale
  61414. */
  61415. scale: Vector2;
  61416. /**
  61417. * The Frames offset
  61418. */
  61419. offset: Vector2;
  61420. /**
  61421. * Initializes a texture package frame.
  61422. * @param id The numerical frame identifier
  61423. * @param scale Scalar Vector2 for UV frame
  61424. * @param offset Vector2 for the frame position in UV units.
  61425. * @returns TexturePackerFrame
  61426. */
  61427. constructor(id: number, scale: Vector2, offset: Vector2);
  61428. }
  61429. }
  61430. declare module BABYLON {
  61431. /**
  61432. * Defines the basic options interface of a TexturePacker
  61433. */
  61434. export interface ITexturePackerOptions {
  61435. /**
  61436. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61437. */
  61438. map?: string[];
  61439. /**
  61440. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61441. */
  61442. uvsIn?: string;
  61443. /**
  61444. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61445. */
  61446. uvsOut?: string;
  61447. /**
  61448. * number representing the layout style. Defaults to LAYOUT_STRIP
  61449. */
  61450. layout?: number;
  61451. /**
  61452. * number of columns if using custom column count layout(2). This defaults to 4.
  61453. */
  61454. colnum?: number;
  61455. /**
  61456. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61457. */
  61458. updateInputMeshes?: boolean;
  61459. /**
  61460. * boolean flag to dispose all the source textures. Defaults to true.
  61461. */
  61462. disposeSources?: boolean;
  61463. /**
  61464. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61465. */
  61466. fillBlanks?: boolean;
  61467. /**
  61468. * string value representing the context fill style color. Defaults to 'black'.
  61469. */
  61470. customFillColor?: string;
  61471. /**
  61472. * Width and Height Value of each Frame in the TexturePacker Sets
  61473. */
  61474. frameSize?: number;
  61475. /**
  61476. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61477. */
  61478. paddingRatio?: number;
  61479. /**
  61480. * Number that declares the fill method for the padding gutter.
  61481. */
  61482. paddingMode?: number;
  61483. /**
  61484. * If in SUBUV_COLOR padding mode what color to use.
  61485. */
  61486. paddingColor?: Color3 | Color4;
  61487. }
  61488. /**
  61489. * Defines the basic interface of a TexturePacker JSON File
  61490. */
  61491. export interface ITexturePackerJSON {
  61492. /**
  61493. * The frame ID
  61494. */
  61495. name: string;
  61496. /**
  61497. * The base64 channel data
  61498. */
  61499. sets: any;
  61500. /**
  61501. * The options of the Packer
  61502. */
  61503. options: ITexturePackerOptions;
  61504. /**
  61505. * The frame data of the Packer
  61506. */
  61507. frames: Array<number>;
  61508. }
  61509. /**
  61510. * This is a support class that generates a series of packed texture sets.
  61511. * @see https://doc.babylonjs.com/babylon101/materials
  61512. */
  61513. export class TexturePacker {
  61514. /** Packer Layout Constant 0 */
  61515. static readonly LAYOUT_STRIP: number;
  61516. /** Packer Layout Constant 1 */
  61517. static readonly LAYOUT_POWER2: number;
  61518. /** Packer Layout Constant 2 */
  61519. static readonly LAYOUT_COLNUM: number;
  61520. /** Packer Layout Constant 0 */
  61521. static readonly SUBUV_WRAP: number;
  61522. /** Packer Layout Constant 1 */
  61523. static readonly SUBUV_EXTEND: number;
  61524. /** Packer Layout Constant 2 */
  61525. static readonly SUBUV_COLOR: number;
  61526. /** The Name of the Texture Package */
  61527. name: string;
  61528. /** The scene scope of the TexturePacker */
  61529. scene: Scene;
  61530. /** The Meshes to target */
  61531. meshes: AbstractMesh[];
  61532. /** Arguments passed with the Constructor */
  61533. options: ITexturePackerOptions;
  61534. /** The promise that is started upon initialization */
  61535. promise: Nullable<Promise<TexturePacker | string>>;
  61536. /** The Container object for the channel sets that are generated */
  61537. sets: object;
  61538. /** The Container array for the frames that are generated */
  61539. frames: TexturePackerFrame[];
  61540. /** The expected number of textures the system is parsing. */
  61541. private _expecting;
  61542. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61543. private _paddingValue;
  61544. /**
  61545. * Initializes a texture package series from an array of meshes or a single mesh.
  61546. * @param name The name of the package
  61547. * @param meshes The target meshes to compose the package from
  61548. * @param options The arguments that texture packer should follow while building.
  61549. * @param scene The scene which the textures are scoped to.
  61550. * @returns TexturePacker
  61551. */
  61552. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61553. /**
  61554. * Starts the package process
  61555. * @param resolve The promises resolution function
  61556. * @returns TexturePacker
  61557. */
  61558. private _createFrames;
  61559. /**
  61560. * Calculates the Size of the Channel Sets
  61561. * @returns Vector2
  61562. */
  61563. private _calculateSize;
  61564. /**
  61565. * Calculates the UV data for the frames.
  61566. * @param baseSize the base frameSize
  61567. * @param padding the base frame padding
  61568. * @param dtSize size of the Dynamic Texture for that channel
  61569. * @param dtUnits is 1/dtSize
  61570. * @param update flag to update the input meshes
  61571. */
  61572. private _calculateMeshUVFrames;
  61573. /**
  61574. * Calculates the frames Offset.
  61575. * @param index of the frame
  61576. * @returns Vector2
  61577. */
  61578. private _getFrameOffset;
  61579. /**
  61580. * Updates a Mesh to the frame data
  61581. * @param mesh that is the target
  61582. * @param frameID or the frame index
  61583. */
  61584. private _updateMeshUV;
  61585. /**
  61586. * Updates a Meshes materials to use the texture packer channels
  61587. * @param m is the mesh to target
  61588. * @param force all channels on the packer to be set.
  61589. */
  61590. private _updateTextureReferences;
  61591. /**
  61592. * Public method to set a Mesh to a frame
  61593. * @param m that is the target
  61594. * @param frameID or the frame index
  61595. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61596. */
  61597. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61598. /**
  61599. * Starts the async promise to compile the texture packer.
  61600. * @returns Promise<void>
  61601. */
  61602. processAsync(): Promise<void>;
  61603. /**
  61604. * Disposes all textures associated with this packer
  61605. */
  61606. dispose(): void;
  61607. /**
  61608. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61609. * @param imageType is the image type to use.
  61610. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61611. */
  61612. download(imageType?: string, quality?: number): void;
  61613. /**
  61614. * Public method to load a texturePacker JSON file.
  61615. * @param data of the JSON file in string format.
  61616. */
  61617. updateFromJSON(data: string): void;
  61618. }
  61619. }
  61620. declare module BABYLON {
  61621. /**
  61622. * 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.
  61623. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61624. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61625. */
  61626. export class CustomProceduralTexture extends ProceduralTexture {
  61627. private _animate;
  61628. private _time;
  61629. private _config;
  61630. private _texturePath;
  61631. /**
  61632. * Instantiates a new Custom Procedural Texture.
  61633. * 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.
  61634. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61635. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61636. * @param name Define the name of the texture
  61637. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61638. * @param size Define the size of the texture to create
  61639. * @param scene Define the scene the texture belongs to
  61640. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61641. * @param generateMipMaps Define if the texture should creates mip maps or not
  61642. */
  61643. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61644. private _loadJson;
  61645. /**
  61646. * Is the texture ready to be used ? (rendered at least once)
  61647. * @returns true if ready, otherwise, false.
  61648. */
  61649. isReady(): boolean;
  61650. /**
  61651. * Render the texture to its associated render target.
  61652. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61653. */
  61654. render(useCameraPostProcess?: boolean): void;
  61655. /**
  61656. * Update the list of dependant textures samplers in the shader.
  61657. */
  61658. updateTextures(): void;
  61659. /**
  61660. * Update the uniform values of the procedural texture in the shader.
  61661. */
  61662. updateShaderUniforms(): void;
  61663. /**
  61664. * Define if the texture animates or not.
  61665. */
  61666. get animate(): boolean;
  61667. set animate(value: boolean);
  61668. }
  61669. }
  61670. declare module BABYLON {
  61671. /** @hidden */
  61672. export var noisePixelShader: {
  61673. name: string;
  61674. shader: string;
  61675. };
  61676. }
  61677. declare module BABYLON {
  61678. /**
  61679. * Class used to generate noise procedural textures
  61680. */
  61681. export class NoiseProceduralTexture extends ProceduralTexture {
  61682. private _time;
  61683. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61684. brightness: number;
  61685. /** Defines the number of octaves to process */
  61686. octaves: number;
  61687. /** Defines the level of persistence (0.8 by default) */
  61688. persistence: number;
  61689. /** Gets or sets animation speed factor (default is 1) */
  61690. animationSpeedFactor: number;
  61691. /**
  61692. * Creates a new NoiseProceduralTexture
  61693. * @param name defines the name fo the texture
  61694. * @param size defines the size of the texture (default is 256)
  61695. * @param scene defines the hosting scene
  61696. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61697. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61698. */
  61699. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61700. private _updateShaderUniforms;
  61701. protected _getDefines(): string;
  61702. /** Generate the current state of the procedural texture */
  61703. render(useCameraPostProcess?: boolean): void;
  61704. /**
  61705. * Serializes this noise procedural texture
  61706. * @returns a serialized noise procedural texture object
  61707. */
  61708. serialize(): any;
  61709. /**
  61710. * Clone the texture.
  61711. * @returns the cloned texture
  61712. */
  61713. clone(): NoiseProceduralTexture;
  61714. /**
  61715. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61716. * @param parsedTexture defines parsed texture data
  61717. * @param scene defines the current scene
  61718. * @param rootUrl defines the root URL containing noise procedural texture information
  61719. * @returns a parsed NoiseProceduralTexture
  61720. */
  61721. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61722. }
  61723. }
  61724. declare module BABYLON {
  61725. /**
  61726. * Raw cube texture where the raw buffers are passed in
  61727. */
  61728. export class RawCubeTexture extends CubeTexture {
  61729. /**
  61730. * Creates a cube texture where the raw buffers are passed in.
  61731. * @param scene defines the scene the texture is attached to
  61732. * @param data defines the array of data to use to create each face
  61733. * @param size defines the size of the textures
  61734. * @param format defines the format of the data
  61735. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61736. * @param generateMipMaps defines if the engine should generate the mip levels
  61737. * @param invertY defines if data must be stored with Y axis inverted
  61738. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61739. * @param compression defines the compression used (null by default)
  61740. */
  61741. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61742. /**
  61743. * Updates the raw cube texture.
  61744. * @param data defines the data to store
  61745. * @param format defines the data format
  61746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61747. * @param invertY defines if data must be stored with Y axis inverted
  61748. * @param compression defines the compression used (null by default)
  61749. * @param level defines which level of the texture to update
  61750. */
  61751. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61752. /**
  61753. * Updates a raw cube texture with RGBD encoded data.
  61754. * @param data defines the array of data [mipmap][face] to use to create each face
  61755. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61758. * @returns a promsie that resolves when the operation is complete
  61759. */
  61760. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61761. /**
  61762. * Clones the raw cube texture.
  61763. * @return a new cube texture
  61764. */
  61765. clone(): CubeTexture;
  61766. /** @hidden */
  61767. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61768. }
  61769. }
  61770. declare module BABYLON {
  61771. /**
  61772. * Class used to store 2D array textures containing user data
  61773. */
  61774. export class RawTexture2DArray extends Texture {
  61775. /** Gets or sets the texture format to use */
  61776. format: number;
  61777. /**
  61778. * Create a new RawTexture2DArray
  61779. * @param data defines the data of the texture
  61780. * @param width defines the width of the texture
  61781. * @param height defines the height of the texture
  61782. * @param depth defines the number of layers of the texture
  61783. * @param format defines the texture format to use
  61784. * @param scene defines the hosting scene
  61785. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61786. * @param invertY defines if texture must be stored with Y axis inverted
  61787. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61788. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61789. */
  61790. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61791. /** Gets or sets the texture format to use */
  61792. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61793. /**
  61794. * Update the texture with new data
  61795. * @param data defines the data to store in the texture
  61796. */
  61797. update(data: ArrayBufferView): void;
  61798. }
  61799. }
  61800. declare module BABYLON {
  61801. /**
  61802. * Class used to store 3D textures containing user data
  61803. */
  61804. export class RawTexture3D extends Texture {
  61805. /** Gets or sets the texture format to use */
  61806. format: number;
  61807. /**
  61808. * Create a new RawTexture3D
  61809. * @param data defines the data of the texture
  61810. * @param width defines the width of the texture
  61811. * @param height defines the height of the texture
  61812. * @param depth defines the depth of the texture
  61813. * @param format defines the texture format to use
  61814. * @param scene defines the hosting scene
  61815. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61816. * @param invertY defines if texture must be stored with Y axis inverted
  61817. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61818. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61819. */
  61820. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61821. /** Gets or sets the texture format to use */
  61822. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61823. /**
  61824. * Update the texture with new data
  61825. * @param data defines the data to store in the texture
  61826. */
  61827. update(data: ArrayBufferView): void;
  61828. }
  61829. }
  61830. declare module BABYLON {
  61831. /**
  61832. * Creates a refraction texture used by refraction channel of the standard material.
  61833. * It is like a mirror but to see through a material.
  61834. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61835. */
  61836. export class RefractionTexture extends RenderTargetTexture {
  61837. /**
  61838. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61839. * 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.
  61840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61841. */
  61842. refractionPlane: Plane;
  61843. /**
  61844. * Define how deep under the surface we should see.
  61845. */
  61846. depth: number;
  61847. /**
  61848. * Creates a refraction texture used by refraction channel of the standard material.
  61849. * It is like a mirror but to see through a material.
  61850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61851. * @param name Define the texture name
  61852. * @param size Define the size of the underlying texture
  61853. * @param scene Define the scene the refraction belongs to
  61854. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61855. */
  61856. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61857. /**
  61858. * Clone the refraction texture.
  61859. * @returns the cloned texture
  61860. */
  61861. clone(): RefractionTexture;
  61862. /**
  61863. * Serialize the texture to a JSON representation you could use in Parse later on
  61864. * @returns the serialized JSON representation
  61865. */
  61866. serialize(): any;
  61867. }
  61868. }
  61869. declare module BABYLON {
  61870. /**
  61871. * Block used to add support for vertex skinning (bones)
  61872. */
  61873. export class BonesBlock extends NodeMaterialBlock {
  61874. /**
  61875. * Creates a new BonesBlock
  61876. * @param name defines the block name
  61877. */
  61878. constructor(name: string);
  61879. /**
  61880. * Initialize the block and prepare the context for build
  61881. * @param state defines the state that will be used for the build
  61882. */
  61883. initialize(state: NodeMaterialBuildState): void;
  61884. /**
  61885. * Gets the current class name
  61886. * @returns the class name
  61887. */
  61888. getClassName(): string;
  61889. /**
  61890. * Gets the matrix indices input component
  61891. */
  61892. get matricesIndices(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the matrix weights input component
  61895. */
  61896. get matricesWeights(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the extra matrix indices input component
  61899. */
  61900. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61901. /**
  61902. * Gets the extra matrix weights input component
  61903. */
  61904. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61905. /**
  61906. * Gets the world input component
  61907. */
  61908. get world(): NodeMaterialConnectionPoint;
  61909. /**
  61910. * Gets the output component
  61911. */
  61912. get output(): NodeMaterialConnectionPoint;
  61913. autoConfigure(material: NodeMaterial): void;
  61914. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61917. protected _buildBlock(state: NodeMaterialBuildState): this;
  61918. }
  61919. }
  61920. declare module BABYLON {
  61921. /**
  61922. * Block used to add support for instances
  61923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61924. */
  61925. export class InstancesBlock extends NodeMaterialBlock {
  61926. /**
  61927. * Creates a new InstancesBlock
  61928. * @param name defines the block name
  61929. */
  61930. constructor(name: string);
  61931. /**
  61932. * Gets the current class name
  61933. * @returns the class name
  61934. */
  61935. getClassName(): string;
  61936. /**
  61937. * Gets the first world row input component
  61938. */
  61939. get world0(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the second world row input component
  61942. */
  61943. get world1(): NodeMaterialConnectionPoint;
  61944. /**
  61945. * Gets the third world row input component
  61946. */
  61947. get world2(): NodeMaterialConnectionPoint;
  61948. /**
  61949. * Gets the forth world row input component
  61950. */
  61951. get world3(): NodeMaterialConnectionPoint;
  61952. /**
  61953. * Gets the world input component
  61954. */
  61955. get world(): NodeMaterialConnectionPoint;
  61956. /**
  61957. * Gets the output component
  61958. */
  61959. get output(): NodeMaterialConnectionPoint;
  61960. /**
  61961. * Gets the isntanceID component
  61962. */
  61963. get instanceID(): NodeMaterialConnectionPoint;
  61964. autoConfigure(material: NodeMaterial): void;
  61965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61966. protected _buildBlock(state: NodeMaterialBuildState): this;
  61967. }
  61968. }
  61969. declare module BABYLON {
  61970. /**
  61971. * Block used to add morph targets support to vertex shader
  61972. */
  61973. export class MorphTargetsBlock extends NodeMaterialBlock {
  61974. private _repeatableContentAnchor;
  61975. /**
  61976. * Create a new MorphTargetsBlock
  61977. * @param name defines the block name
  61978. */
  61979. constructor(name: string);
  61980. /**
  61981. * Gets the current class name
  61982. * @returns the class name
  61983. */
  61984. getClassName(): string;
  61985. /**
  61986. * Gets the position input component
  61987. */
  61988. get position(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the normal input component
  61991. */
  61992. get normal(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the tangent input component
  61995. */
  61996. get tangent(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the tangent input component
  61999. */
  62000. get uv(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the position output component
  62003. */
  62004. get positionOutput(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the normal output component
  62007. */
  62008. get normalOutput(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the tangent output component
  62011. */
  62012. get tangentOutput(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the tangent output component
  62015. */
  62016. get uvOutput(): NodeMaterialConnectionPoint;
  62017. initialize(state: NodeMaterialBuildState): void;
  62018. autoConfigure(material: NodeMaterial): void;
  62019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62021. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62022. protected _buildBlock(state: NodeMaterialBuildState): this;
  62023. }
  62024. }
  62025. declare module BABYLON {
  62026. /**
  62027. * Block used to get data information from a light
  62028. */
  62029. export class LightInformationBlock extends NodeMaterialBlock {
  62030. private _lightDataUniformName;
  62031. private _lightColorUniformName;
  62032. private _lightTypeDefineName;
  62033. /**
  62034. * Gets or sets the light associated with this block
  62035. */
  62036. light: Nullable<Light>;
  62037. /**
  62038. * Creates a new LightInformationBlock
  62039. * @param name defines the block name
  62040. */
  62041. constructor(name: string);
  62042. /**
  62043. * Gets the current class name
  62044. * @returns the class name
  62045. */
  62046. getClassName(): string;
  62047. /**
  62048. * Gets the world position input component
  62049. */
  62050. get worldPosition(): NodeMaterialConnectionPoint;
  62051. /**
  62052. * Gets the direction output component
  62053. */
  62054. get direction(): NodeMaterialConnectionPoint;
  62055. /**
  62056. * Gets the direction output component
  62057. */
  62058. get color(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the direction output component
  62061. */
  62062. get intensity(): NodeMaterialConnectionPoint;
  62063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62065. protected _buildBlock(state: NodeMaterialBuildState): this;
  62066. serialize(): any;
  62067. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62068. }
  62069. }
  62070. declare module BABYLON {
  62071. /**
  62072. * Block used to add image processing support to fragment shader
  62073. */
  62074. export class ImageProcessingBlock extends NodeMaterialBlock {
  62075. /**
  62076. * Create a new ImageProcessingBlock
  62077. * @param name defines the block name
  62078. */
  62079. constructor(name: string);
  62080. /**
  62081. * Gets the current class name
  62082. * @returns the class name
  62083. */
  62084. getClassName(): string;
  62085. /**
  62086. * Gets the color input component
  62087. */
  62088. get color(): NodeMaterialConnectionPoint;
  62089. /**
  62090. * Gets the output component
  62091. */
  62092. get output(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Initialize the block and prepare the context for build
  62095. * @param state defines the state that will be used for the build
  62096. */
  62097. initialize(state: NodeMaterialBuildState): void;
  62098. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62101. protected _buildBlock(state: NodeMaterialBuildState): this;
  62102. }
  62103. }
  62104. declare module BABYLON {
  62105. /**
  62106. * Block used to pertub normals based on a normal map
  62107. */
  62108. export class PerturbNormalBlock extends NodeMaterialBlock {
  62109. private _tangentSpaceParameterName;
  62110. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62111. invertX: boolean;
  62112. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62113. invertY: boolean;
  62114. /**
  62115. * Create a new PerturbNormalBlock
  62116. * @param name defines the block name
  62117. */
  62118. constructor(name: string);
  62119. /**
  62120. * Gets the current class name
  62121. * @returns the class name
  62122. */
  62123. getClassName(): string;
  62124. /**
  62125. * Gets the world position input component
  62126. */
  62127. get worldPosition(): NodeMaterialConnectionPoint;
  62128. /**
  62129. * Gets the world normal input component
  62130. */
  62131. get worldNormal(): NodeMaterialConnectionPoint;
  62132. /**
  62133. * Gets the world tangent input component
  62134. */
  62135. get worldTangent(): NodeMaterialConnectionPoint;
  62136. /**
  62137. * Gets the uv input component
  62138. */
  62139. get uv(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the normal map color input component
  62142. */
  62143. get normalMapColor(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the strength input component
  62146. */
  62147. get strength(): NodeMaterialConnectionPoint;
  62148. /**
  62149. * Gets the output component
  62150. */
  62151. get output(): NodeMaterialConnectionPoint;
  62152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62154. autoConfigure(material: NodeMaterial): void;
  62155. protected _buildBlock(state: NodeMaterialBuildState): this;
  62156. protected _dumpPropertiesCode(): string;
  62157. serialize(): any;
  62158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62159. }
  62160. }
  62161. declare module BABYLON {
  62162. /**
  62163. * Block used to discard a pixel if a value is smaller than a cutoff
  62164. */
  62165. export class DiscardBlock extends NodeMaterialBlock {
  62166. /**
  62167. * Create a new DiscardBlock
  62168. * @param name defines the block name
  62169. */
  62170. constructor(name: string);
  62171. /**
  62172. * Gets the current class name
  62173. * @returns the class name
  62174. */
  62175. getClassName(): string;
  62176. /**
  62177. * Gets the color input component
  62178. */
  62179. get value(): NodeMaterialConnectionPoint;
  62180. /**
  62181. * Gets the cutoff input component
  62182. */
  62183. get cutoff(): NodeMaterialConnectionPoint;
  62184. protected _buildBlock(state: NodeMaterialBuildState): this;
  62185. }
  62186. }
  62187. declare module BABYLON {
  62188. /**
  62189. * Block used to test if the fragment shader is front facing
  62190. */
  62191. export class FrontFacingBlock extends NodeMaterialBlock {
  62192. /**
  62193. * Creates a new FrontFacingBlock
  62194. * @param name defines the block name
  62195. */
  62196. constructor(name: string);
  62197. /**
  62198. * Gets the current class name
  62199. * @returns the class name
  62200. */
  62201. getClassName(): string;
  62202. /**
  62203. * Gets the output component
  62204. */
  62205. get output(): NodeMaterialConnectionPoint;
  62206. protected _buildBlock(state: NodeMaterialBuildState): this;
  62207. }
  62208. }
  62209. declare module BABYLON {
  62210. /**
  62211. * Block used to get the derivative value on x and y of a given input
  62212. */
  62213. export class DerivativeBlock extends NodeMaterialBlock {
  62214. /**
  62215. * Create a new DerivativeBlock
  62216. * @param name defines the block name
  62217. */
  62218. constructor(name: string);
  62219. /**
  62220. * Gets the current class name
  62221. * @returns the class name
  62222. */
  62223. getClassName(): string;
  62224. /**
  62225. * Gets the input component
  62226. */
  62227. get input(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the derivative output on x
  62230. */
  62231. get dx(): NodeMaterialConnectionPoint;
  62232. /**
  62233. * Gets the derivative output on y
  62234. */
  62235. get dy(): NodeMaterialConnectionPoint;
  62236. protected _buildBlock(state: NodeMaterialBuildState): this;
  62237. }
  62238. }
  62239. declare module BABYLON {
  62240. /**
  62241. * Block used to make gl_FragCoord available
  62242. */
  62243. export class FragCoordBlock extends NodeMaterialBlock {
  62244. /**
  62245. * Creates a new FragCoordBlock
  62246. * @param name defines the block name
  62247. */
  62248. constructor(name: string);
  62249. /**
  62250. * Gets the current class name
  62251. * @returns the class name
  62252. */
  62253. getClassName(): string;
  62254. /**
  62255. * Gets the xy component
  62256. */
  62257. get xy(): NodeMaterialConnectionPoint;
  62258. /**
  62259. * Gets the xyz component
  62260. */
  62261. get xyz(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the xyzw component
  62264. */
  62265. get xyzw(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the x component
  62268. */
  62269. get x(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the y component
  62272. */
  62273. get y(): NodeMaterialConnectionPoint;
  62274. /**
  62275. * Gets the z component
  62276. */
  62277. get z(): NodeMaterialConnectionPoint;
  62278. /**
  62279. * Gets the w component
  62280. */
  62281. get output(): NodeMaterialConnectionPoint;
  62282. protected writeOutputs(state: NodeMaterialBuildState): string;
  62283. protected _buildBlock(state: NodeMaterialBuildState): this;
  62284. }
  62285. }
  62286. declare module BABYLON {
  62287. /**
  62288. * Block used to get the screen sizes
  62289. */
  62290. export class ScreenSizeBlock extends NodeMaterialBlock {
  62291. private _varName;
  62292. private _scene;
  62293. /**
  62294. * Creates a new ScreenSizeBlock
  62295. * @param name defines the block name
  62296. */
  62297. constructor(name: string);
  62298. /**
  62299. * Gets the current class name
  62300. * @returns the class name
  62301. */
  62302. getClassName(): string;
  62303. /**
  62304. * Gets the xy component
  62305. */
  62306. get xy(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the x component
  62309. */
  62310. get x(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the y component
  62313. */
  62314. get y(): NodeMaterialConnectionPoint;
  62315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62316. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62317. protected _buildBlock(state: NodeMaterialBuildState): this;
  62318. }
  62319. }
  62320. declare module BABYLON {
  62321. /**
  62322. * Block used to add support for scene fog
  62323. */
  62324. export class FogBlock extends NodeMaterialBlock {
  62325. private _fogDistanceName;
  62326. private _fogParameters;
  62327. /**
  62328. * Create a new FogBlock
  62329. * @param name defines the block name
  62330. */
  62331. constructor(name: string);
  62332. /**
  62333. * Gets the current class name
  62334. * @returns the class name
  62335. */
  62336. getClassName(): string;
  62337. /**
  62338. * Gets the world position input component
  62339. */
  62340. get worldPosition(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the view input component
  62343. */
  62344. get view(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the color input component
  62347. */
  62348. get input(): NodeMaterialConnectionPoint;
  62349. /**
  62350. * Gets the fog color input component
  62351. */
  62352. get fogColor(): NodeMaterialConnectionPoint;
  62353. /**
  62354. * Gets the output component
  62355. */
  62356. get output(): NodeMaterialConnectionPoint;
  62357. autoConfigure(material: NodeMaterial): void;
  62358. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62359. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62360. protected _buildBlock(state: NodeMaterialBuildState): this;
  62361. }
  62362. }
  62363. declare module BABYLON {
  62364. /**
  62365. * Block used to add light in the fragment shader
  62366. */
  62367. export class LightBlock extends NodeMaterialBlock {
  62368. private _lightId;
  62369. /**
  62370. * Gets or sets the light associated with this block
  62371. */
  62372. light: Nullable<Light>;
  62373. /**
  62374. * Create a new LightBlock
  62375. * @param name defines the block name
  62376. */
  62377. constructor(name: string);
  62378. /**
  62379. * Gets the current class name
  62380. * @returns the class name
  62381. */
  62382. getClassName(): string;
  62383. /**
  62384. * Gets the world position input component
  62385. */
  62386. get worldPosition(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the world normal input component
  62389. */
  62390. get worldNormal(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the camera (or eye) position component
  62393. */
  62394. get cameraPosition(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the glossiness component
  62397. */
  62398. get glossiness(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the glossinness power component
  62401. */
  62402. get glossPower(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the diffuse color component
  62405. */
  62406. get diffuseColor(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the specular color component
  62409. */
  62410. get specularColor(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the diffuse output component
  62413. */
  62414. get diffuseOutput(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the specular output component
  62417. */
  62418. get specularOutput(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the shadow output component
  62421. */
  62422. get shadow(): NodeMaterialConnectionPoint;
  62423. autoConfigure(material: NodeMaterial): void;
  62424. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62425. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62427. private _injectVertexCode;
  62428. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62429. serialize(): any;
  62430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62431. }
  62432. }
  62433. declare module BABYLON {
  62434. /**
  62435. * Block used to read a reflection texture from a sampler
  62436. */
  62437. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62438. /**
  62439. * Create a new ReflectionTextureBlock
  62440. * @param name defines the block name
  62441. */
  62442. constructor(name: string);
  62443. /**
  62444. * Gets the current class name
  62445. * @returns the class name
  62446. */
  62447. getClassName(): string;
  62448. /**
  62449. * Gets the world position input component
  62450. */
  62451. get position(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the world position input component
  62454. */
  62455. get worldPosition(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the world normal input component
  62458. */
  62459. get worldNormal(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the world input component
  62462. */
  62463. get world(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the camera (or eye) position component
  62466. */
  62467. get cameraPosition(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the view input component
  62470. */
  62471. get view(): NodeMaterialConnectionPoint;
  62472. /**
  62473. * Gets the rgb output component
  62474. */
  62475. get rgb(): NodeMaterialConnectionPoint;
  62476. /**
  62477. * Gets the rgba output component
  62478. */
  62479. get rgba(): NodeMaterialConnectionPoint;
  62480. /**
  62481. * Gets the r output component
  62482. */
  62483. get r(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the g output component
  62486. */
  62487. get g(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the b output component
  62490. */
  62491. get b(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the a output component
  62494. */
  62495. get a(): NodeMaterialConnectionPoint;
  62496. autoConfigure(material: NodeMaterial): void;
  62497. protected _buildBlock(state: NodeMaterialBuildState): this;
  62498. }
  62499. }
  62500. declare module BABYLON {
  62501. /**
  62502. * Block used to add 2 vectors
  62503. */
  62504. export class AddBlock extends NodeMaterialBlock {
  62505. /**
  62506. * Creates a new AddBlock
  62507. * @param name defines the block name
  62508. */
  62509. constructor(name: string);
  62510. /**
  62511. * Gets the current class name
  62512. * @returns the class name
  62513. */
  62514. getClassName(): string;
  62515. /**
  62516. * Gets the left operand input component
  62517. */
  62518. get left(): NodeMaterialConnectionPoint;
  62519. /**
  62520. * Gets the right operand input component
  62521. */
  62522. get right(): NodeMaterialConnectionPoint;
  62523. /**
  62524. * Gets the output component
  62525. */
  62526. get output(): NodeMaterialConnectionPoint;
  62527. protected _buildBlock(state: NodeMaterialBuildState): this;
  62528. }
  62529. }
  62530. declare module BABYLON {
  62531. /**
  62532. * Block used to scale a vector by a float
  62533. */
  62534. export class ScaleBlock extends NodeMaterialBlock {
  62535. /**
  62536. * Creates a new ScaleBlock
  62537. * @param name defines the block name
  62538. */
  62539. constructor(name: string);
  62540. /**
  62541. * Gets the current class name
  62542. * @returns the class name
  62543. */
  62544. getClassName(): string;
  62545. /**
  62546. * Gets the input component
  62547. */
  62548. get input(): NodeMaterialConnectionPoint;
  62549. /**
  62550. * Gets the factor input component
  62551. */
  62552. get factor(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the output component
  62555. */
  62556. get output(): NodeMaterialConnectionPoint;
  62557. protected _buildBlock(state: NodeMaterialBuildState): this;
  62558. }
  62559. }
  62560. declare module BABYLON {
  62561. /**
  62562. * Block used to clamp a float
  62563. */
  62564. export class ClampBlock extends NodeMaterialBlock {
  62565. /** Gets or sets the minimum range */
  62566. minimum: number;
  62567. /** Gets or sets the maximum range */
  62568. maximum: number;
  62569. /**
  62570. * Creates a new ClampBlock
  62571. * @param name defines the block name
  62572. */
  62573. constructor(name: string);
  62574. /**
  62575. * Gets the current class name
  62576. * @returns the class name
  62577. */
  62578. getClassName(): string;
  62579. /**
  62580. * Gets the value input component
  62581. */
  62582. get value(): NodeMaterialConnectionPoint;
  62583. /**
  62584. * Gets the output component
  62585. */
  62586. get output(): NodeMaterialConnectionPoint;
  62587. protected _buildBlock(state: NodeMaterialBuildState): this;
  62588. protected _dumpPropertiesCode(): string;
  62589. serialize(): any;
  62590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62591. }
  62592. }
  62593. declare module BABYLON {
  62594. /**
  62595. * Block used to apply a cross product between 2 vectors
  62596. */
  62597. export class CrossBlock extends NodeMaterialBlock {
  62598. /**
  62599. * Creates a new CrossBlock
  62600. * @param name defines the block name
  62601. */
  62602. constructor(name: string);
  62603. /**
  62604. * Gets the current class name
  62605. * @returns the class name
  62606. */
  62607. getClassName(): string;
  62608. /**
  62609. * Gets the left operand input component
  62610. */
  62611. get left(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the right operand input component
  62614. */
  62615. get right(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the output component
  62618. */
  62619. get output(): NodeMaterialConnectionPoint;
  62620. protected _buildBlock(state: NodeMaterialBuildState): this;
  62621. }
  62622. }
  62623. declare module BABYLON {
  62624. /**
  62625. * Block used to apply a dot product between 2 vectors
  62626. */
  62627. export class DotBlock extends NodeMaterialBlock {
  62628. /**
  62629. * Creates a new DotBlock
  62630. * @param name defines the block name
  62631. */
  62632. constructor(name: string);
  62633. /**
  62634. * Gets the current class name
  62635. * @returns the class name
  62636. */
  62637. getClassName(): string;
  62638. /**
  62639. * Gets the left operand input component
  62640. */
  62641. get left(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the right operand input component
  62644. */
  62645. get right(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the output component
  62648. */
  62649. get output(): NodeMaterialConnectionPoint;
  62650. protected _buildBlock(state: NodeMaterialBuildState): this;
  62651. }
  62652. }
  62653. declare module BABYLON {
  62654. /**
  62655. * Block used to normalize a vector
  62656. */
  62657. export class NormalizeBlock extends NodeMaterialBlock {
  62658. /**
  62659. * Creates a new NormalizeBlock
  62660. * @param name defines the block name
  62661. */
  62662. constructor(name: string);
  62663. /**
  62664. * Gets the current class name
  62665. * @returns the class name
  62666. */
  62667. getClassName(): string;
  62668. /**
  62669. * Gets the input component
  62670. */
  62671. get input(): NodeMaterialConnectionPoint;
  62672. /**
  62673. * Gets the output component
  62674. */
  62675. get output(): NodeMaterialConnectionPoint;
  62676. protected _buildBlock(state: NodeMaterialBuildState): this;
  62677. }
  62678. }
  62679. declare module BABYLON {
  62680. /**
  62681. * Operations supported by the Trigonometry block
  62682. */
  62683. export enum TrigonometryBlockOperations {
  62684. /** Cos */
  62685. Cos = 0,
  62686. /** Sin */
  62687. Sin = 1,
  62688. /** Abs */
  62689. Abs = 2,
  62690. /** Exp */
  62691. Exp = 3,
  62692. /** Exp2 */
  62693. Exp2 = 4,
  62694. /** Round */
  62695. Round = 5,
  62696. /** Floor */
  62697. Floor = 6,
  62698. /** Ceiling */
  62699. Ceiling = 7,
  62700. /** Square root */
  62701. Sqrt = 8,
  62702. /** Log */
  62703. Log = 9,
  62704. /** Tangent */
  62705. Tan = 10,
  62706. /** Arc tangent */
  62707. ArcTan = 11,
  62708. /** Arc cosinus */
  62709. ArcCos = 12,
  62710. /** Arc sinus */
  62711. ArcSin = 13,
  62712. /** Fraction */
  62713. Fract = 14,
  62714. /** Sign */
  62715. Sign = 15,
  62716. /** To radians (from degrees) */
  62717. Radians = 16,
  62718. /** To degrees (from radians) */
  62719. Degrees = 17
  62720. }
  62721. /**
  62722. * Block used to apply trigonometry operation to floats
  62723. */
  62724. export class TrigonometryBlock extends NodeMaterialBlock {
  62725. /**
  62726. * Gets or sets the operation applied by the block
  62727. */
  62728. operation: TrigonometryBlockOperations;
  62729. /**
  62730. * Creates a new TrigonometryBlock
  62731. * @param name defines the block name
  62732. */
  62733. constructor(name: string);
  62734. /**
  62735. * Gets the current class name
  62736. * @returns the class name
  62737. */
  62738. getClassName(): string;
  62739. /**
  62740. * Gets the input component
  62741. */
  62742. get input(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the output component
  62745. */
  62746. get output(): NodeMaterialConnectionPoint;
  62747. protected _buildBlock(state: NodeMaterialBuildState): this;
  62748. serialize(): any;
  62749. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62750. protected _dumpPropertiesCode(): string;
  62751. }
  62752. }
  62753. declare module BABYLON {
  62754. /**
  62755. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62756. */
  62757. export class ColorMergerBlock extends NodeMaterialBlock {
  62758. /**
  62759. * Create a new ColorMergerBlock
  62760. * @param name defines the block name
  62761. */
  62762. constructor(name: string);
  62763. /**
  62764. * Gets the current class name
  62765. * @returns the class name
  62766. */
  62767. getClassName(): string;
  62768. /**
  62769. * Gets the rgb component (input)
  62770. */
  62771. get rgbIn(): NodeMaterialConnectionPoint;
  62772. /**
  62773. * Gets the r component (input)
  62774. */
  62775. get r(): NodeMaterialConnectionPoint;
  62776. /**
  62777. * Gets the g component (input)
  62778. */
  62779. get g(): NodeMaterialConnectionPoint;
  62780. /**
  62781. * Gets the b component (input)
  62782. */
  62783. get b(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the a component (input)
  62786. */
  62787. get a(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the rgba component (output)
  62790. */
  62791. get rgba(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the rgb component (output)
  62794. */
  62795. get rgbOut(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the rgb component (output)
  62798. * @deprecated Please use rgbOut instead.
  62799. */
  62800. get rgb(): NodeMaterialConnectionPoint;
  62801. protected _buildBlock(state: NodeMaterialBuildState): this;
  62802. }
  62803. }
  62804. declare module BABYLON {
  62805. /**
  62806. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62807. */
  62808. export class VectorSplitterBlock extends NodeMaterialBlock {
  62809. /**
  62810. * Create a new VectorSplitterBlock
  62811. * @param name defines the block name
  62812. */
  62813. constructor(name: string);
  62814. /**
  62815. * Gets the current class name
  62816. * @returns the class name
  62817. */
  62818. getClassName(): string;
  62819. /**
  62820. * Gets the xyzw component (input)
  62821. */
  62822. get xyzw(): NodeMaterialConnectionPoint;
  62823. /**
  62824. * Gets the xyz component (input)
  62825. */
  62826. get xyzIn(): NodeMaterialConnectionPoint;
  62827. /**
  62828. * Gets the xy component (input)
  62829. */
  62830. get xyIn(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the xyz component (output)
  62833. */
  62834. get xyzOut(): NodeMaterialConnectionPoint;
  62835. /**
  62836. * Gets the xy component (output)
  62837. */
  62838. get xyOut(): NodeMaterialConnectionPoint;
  62839. /**
  62840. * Gets the x component (output)
  62841. */
  62842. get x(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the y component (output)
  62845. */
  62846. get y(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the z component (output)
  62849. */
  62850. get z(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the w component (output)
  62853. */
  62854. get w(): NodeMaterialConnectionPoint;
  62855. protected _inputRename(name: string): string;
  62856. protected _outputRename(name: string): string;
  62857. protected _buildBlock(state: NodeMaterialBuildState): this;
  62858. }
  62859. }
  62860. declare module BABYLON {
  62861. /**
  62862. * Block used to lerp between 2 values
  62863. */
  62864. export class LerpBlock extends NodeMaterialBlock {
  62865. /**
  62866. * Creates a new LerpBlock
  62867. * @param name defines the block name
  62868. */
  62869. constructor(name: string);
  62870. /**
  62871. * Gets the current class name
  62872. * @returns the class name
  62873. */
  62874. getClassName(): string;
  62875. /**
  62876. * Gets the left operand input component
  62877. */
  62878. get left(): NodeMaterialConnectionPoint;
  62879. /**
  62880. * Gets the right operand input component
  62881. */
  62882. get right(): NodeMaterialConnectionPoint;
  62883. /**
  62884. * Gets the gradient operand input component
  62885. */
  62886. get gradient(): NodeMaterialConnectionPoint;
  62887. /**
  62888. * Gets the output component
  62889. */
  62890. get output(): NodeMaterialConnectionPoint;
  62891. protected _buildBlock(state: NodeMaterialBuildState): this;
  62892. }
  62893. }
  62894. declare module BABYLON {
  62895. /**
  62896. * Block used to divide 2 vectors
  62897. */
  62898. export class DivideBlock extends NodeMaterialBlock {
  62899. /**
  62900. * Creates a new DivideBlock
  62901. * @param name defines the block name
  62902. */
  62903. constructor(name: string);
  62904. /**
  62905. * Gets the current class name
  62906. * @returns the class name
  62907. */
  62908. getClassName(): string;
  62909. /**
  62910. * Gets the left operand input component
  62911. */
  62912. get left(): NodeMaterialConnectionPoint;
  62913. /**
  62914. * Gets the right operand input component
  62915. */
  62916. get right(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the output component
  62919. */
  62920. get output(): NodeMaterialConnectionPoint;
  62921. protected _buildBlock(state: NodeMaterialBuildState): this;
  62922. }
  62923. }
  62924. declare module BABYLON {
  62925. /**
  62926. * Block used to subtract 2 vectors
  62927. */
  62928. export class SubtractBlock extends NodeMaterialBlock {
  62929. /**
  62930. * Creates a new SubtractBlock
  62931. * @param name defines the block name
  62932. */
  62933. constructor(name: string);
  62934. /**
  62935. * Gets the current class name
  62936. * @returns the class name
  62937. */
  62938. getClassName(): string;
  62939. /**
  62940. * Gets the left operand input component
  62941. */
  62942. get left(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the right operand input component
  62945. */
  62946. get right(): NodeMaterialConnectionPoint;
  62947. /**
  62948. * Gets the output component
  62949. */
  62950. get output(): NodeMaterialConnectionPoint;
  62951. protected _buildBlock(state: NodeMaterialBuildState): this;
  62952. }
  62953. }
  62954. declare module BABYLON {
  62955. /**
  62956. * Block used to step a value
  62957. */
  62958. export class StepBlock extends NodeMaterialBlock {
  62959. /**
  62960. * Creates a new StepBlock
  62961. * @param name defines the block name
  62962. */
  62963. constructor(name: string);
  62964. /**
  62965. * Gets the current class name
  62966. * @returns the class name
  62967. */
  62968. getClassName(): string;
  62969. /**
  62970. * Gets the value operand input component
  62971. */
  62972. get value(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the edge operand input component
  62975. */
  62976. get edge(): NodeMaterialConnectionPoint;
  62977. /**
  62978. * Gets the output component
  62979. */
  62980. get output(): NodeMaterialConnectionPoint;
  62981. protected _buildBlock(state: NodeMaterialBuildState): this;
  62982. }
  62983. }
  62984. declare module BABYLON {
  62985. /**
  62986. * Block used to get the opposite (1 - x) of a value
  62987. */
  62988. export class OneMinusBlock extends NodeMaterialBlock {
  62989. /**
  62990. * Creates a new OneMinusBlock
  62991. * @param name defines the block name
  62992. */
  62993. constructor(name: string);
  62994. /**
  62995. * Gets the current class name
  62996. * @returns the class name
  62997. */
  62998. getClassName(): string;
  62999. /**
  63000. * Gets the input component
  63001. */
  63002. get input(): NodeMaterialConnectionPoint;
  63003. /**
  63004. * Gets the output component
  63005. */
  63006. get output(): NodeMaterialConnectionPoint;
  63007. protected _buildBlock(state: NodeMaterialBuildState): this;
  63008. }
  63009. }
  63010. declare module BABYLON {
  63011. /**
  63012. * Block used to get the view direction
  63013. */
  63014. export class ViewDirectionBlock extends NodeMaterialBlock {
  63015. /**
  63016. * Creates a new ViewDirectionBlock
  63017. * @param name defines the block name
  63018. */
  63019. constructor(name: string);
  63020. /**
  63021. * Gets the current class name
  63022. * @returns the class name
  63023. */
  63024. getClassName(): string;
  63025. /**
  63026. * Gets the world position component
  63027. */
  63028. get worldPosition(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the camera position component
  63031. */
  63032. get cameraPosition(): NodeMaterialConnectionPoint;
  63033. /**
  63034. * Gets the output component
  63035. */
  63036. get output(): NodeMaterialConnectionPoint;
  63037. autoConfigure(material: NodeMaterial): void;
  63038. protected _buildBlock(state: NodeMaterialBuildState): this;
  63039. }
  63040. }
  63041. declare module BABYLON {
  63042. /**
  63043. * Block used to compute fresnel value
  63044. */
  63045. export class FresnelBlock extends NodeMaterialBlock {
  63046. /**
  63047. * Create a new FresnelBlock
  63048. * @param name defines the block name
  63049. */
  63050. constructor(name: string);
  63051. /**
  63052. * Gets the current class name
  63053. * @returns the class name
  63054. */
  63055. getClassName(): string;
  63056. /**
  63057. * Gets the world normal input component
  63058. */
  63059. get worldNormal(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the view direction input component
  63062. */
  63063. get viewDirection(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the bias input component
  63066. */
  63067. get bias(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the camera (or eye) position component
  63070. */
  63071. get power(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the fresnel output component
  63074. */
  63075. get fresnel(): NodeMaterialConnectionPoint;
  63076. autoConfigure(material: NodeMaterial): void;
  63077. protected _buildBlock(state: NodeMaterialBuildState): this;
  63078. }
  63079. }
  63080. declare module BABYLON {
  63081. /**
  63082. * Block used to get the max of 2 values
  63083. */
  63084. export class MaxBlock extends NodeMaterialBlock {
  63085. /**
  63086. * Creates a new MaxBlock
  63087. * @param name defines the block name
  63088. */
  63089. constructor(name: string);
  63090. /**
  63091. * Gets the current class name
  63092. * @returns the class name
  63093. */
  63094. getClassName(): string;
  63095. /**
  63096. * Gets the left operand input component
  63097. */
  63098. get left(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the right operand input component
  63101. */
  63102. get right(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the output component
  63105. */
  63106. get output(): NodeMaterialConnectionPoint;
  63107. protected _buildBlock(state: NodeMaterialBuildState): this;
  63108. }
  63109. }
  63110. declare module BABYLON {
  63111. /**
  63112. * Block used to get the min of 2 values
  63113. */
  63114. export class MinBlock extends NodeMaterialBlock {
  63115. /**
  63116. * Creates a new MinBlock
  63117. * @param name defines the block name
  63118. */
  63119. constructor(name: string);
  63120. /**
  63121. * Gets the current class name
  63122. * @returns the class name
  63123. */
  63124. getClassName(): string;
  63125. /**
  63126. * Gets the left operand input component
  63127. */
  63128. get left(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the right operand input component
  63131. */
  63132. get right(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the output component
  63135. */
  63136. get output(): NodeMaterialConnectionPoint;
  63137. protected _buildBlock(state: NodeMaterialBuildState): this;
  63138. }
  63139. }
  63140. declare module BABYLON {
  63141. /**
  63142. * Block used to get the distance between 2 values
  63143. */
  63144. export class DistanceBlock extends NodeMaterialBlock {
  63145. /**
  63146. * Creates a new DistanceBlock
  63147. * @param name defines the block name
  63148. */
  63149. constructor(name: string);
  63150. /**
  63151. * Gets the current class name
  63152. * @returns the class name
  63153. */
  63154. getClassName(): string;
  63155. /**
  63156. * Gets the left operand input component
  63157. */
  63158. get left(): NodeMaterialConnectionPoint;
  63159. /**
  63160. * Gets the right operand input component
  63161. */
  63162. get right(): NodeMaterialConnectionPoint;
  63163. /**
  63164. * Gets the output component
  63165. */
  63166. get output(): NodeMaterialConnectionPoint;
  63167. protected _buildBlock(state: NodeMaterialBuildState): this;
  63168. }
  63169. }
  63170. declare module BABYLON {
  63171. /**
  63172. * Block used to get the length of a vector
  63173. */
  63174. export class LengthBlock extends NodeMaterialBlock {
  63175. /**
  63176. * Creates a new LengthBlock
  63177. * @param name defines the block name
  63178. */
  63179. constructor(name: string);
  63180. /**
  63181. * Gets the current class name
  63182. * @returns the class name
  63183. */
  63184. getClassName(): string;
  63185. /**
  63186. * Gets the value input component
  63187. */
  63188. get value(): NodeMaterialConnectionPoint;
  63189. /**
  63190. * Gets the output component
  63191. */
  63192. get output(): NodeMaterialConnectionPoint;
  63193. protected _buildBlock(state: NodeMaterialBuildState): this;
  63194. }
  63195. }
  63196. declare module BABYLON {
  63197. /**
  63198. * Block used to get negative version of a value (i.e. x * -1)
  63199. */
  63200. export class NegateBlock extends NodeMaterialBlock {
  63201. /**
  63202. * Creates a new NegateBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the value input component
  63213. */
  63214. get value(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the output component
  63217. */
  63218. get output(): NodeMaterialConnectionPoint;
  63219. protected _buildBlock(state: NodeMaterialBuildState): this;
  63220. }
  63221. }
  63222. declare module BABYLON {
  63223. /**
  63224. * Block used to get the value of the first parameter raised to the power of the second
  63225. */
  63226. export class PowBlock extends NodeMaterialBlock {
  63227. /**
  63228. * Creates a new PowBlock
  63229. * @param name defines the block name
  63230. */
  63231. constructor(name: string);
  63232. /**
  63233. * Gets the current class name
  63234. * @returns the class name
  63235. */
  63236. getClassName(): string;
  63237. /**
  63238. * Gets the value operand input component
  63239. */
  63240. get value(): NodeMaterialConnectionPoint;
  63241. /**
  63242. * Gets the power operand input component
  63243. */
  63244. get power(): NodeMaterialConnectionPoint;
  63245. /**
  63246. * Gets the output component
  63247. */
  63248. get output(): NodeMaterialConnectionPoint;
  63249. protected _buildBlock(state: NodeMaterialBuildState): this;
  63250. }
  63251. }
  63252. declare module BABYLON {
  63253. /**
  63254. * Block used to get a random number
  63255. */
  63256. export class RandomNumberBlock extends NodeMaterialBlock {
  63257. /**
  63258. * Creates a new RandomNumberBlock
  63259. * @param name defines the block name
  63260. */
  63261. constructor(name: string);
  63262. /**
  63263. * Gets the current class name
  63264. * @returns the class name
  63265. */
  63266. getClassName(): string;
  63267. /**
  63268. * Gets the seed input component
  63269. */
  63270. get seed(): NodeMaterialConnectionPoint;
  63271. /**
  63272. * Gets the output component
  63273. */
  63274. get output(): NodeMaterialConnectionPoint;
  63275. protected _buildBlock(state: NodeMaterialBuildState): this;
  63276. }
  63277. }
  63278. declare module BABYLON {
  63279. /**
  63280. * Block used to compute arc tangent of 2 values
  63281. */
  63282. export class ArcTan2Block extends NodeMaterialBlock {
  63283. /**
  63284. * Creates a new ArcTan2Block
  63285. * @param name defines the block name
  63286. */
  63287. constructor(name: string);
  63288. /**
  63289. * Gets the current class name
  63290. * @returns the class name
  63291. */
  63292. getClassName(): string;
  63293. /**
  63294. * Gets the x operand input component
  63295. */
  63296. get x(): NodeMaterialConnectionPoint;
  63297. /**
  63298. * Gets the y operand input component
  63299. */
  63300. get y(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the output component
  63303. */
  63304. get output(): NodeMaterialConnectionPoint;
  63305. protected _buildBlock(state: NodeMaterialBuildState): this;
  63306. }
  63307. }
  63308. declare module BABYLON {
  63309. /**
  63310. * Block used to smooth step a value
  63311. */
  63312. export class SmoothStepBlock extends NodeMaterialBlock {
  63313. /**
  63314. * Creates a new SmoothStepBlock
  63315. * @param name defines the block name
  63316. */
  63317. constructor(name: string);
  63318. /**
  63319. * Gets the current class name
  63320. * @returns the class name
  63321. */
  63322. getClassName(): string;
  63323. /**
  63324. * Gets the value operand input component
  63325. */
  63326. get value(): NodeMaterialConnectionPoint;
  63327. /**
  63328. * Gets the first edge operand input component
  63329. */
  63330. get edge0(): NodeMaterialConnectionPoint;
  63331. /**
  63332. * Gets the second edge operand input component
  63333. */
  63334. get edge1(): NodeMaterialConnectionPoint;
  63335. /**
  63336. * Gets the output component
  63337. */
  63338. get output(): NodeMaterialConnectionPoint;
  63339. protected _buildBlock(state: NodeMaterialBuildState): this;
  63340. }
  63341. }
  63342. declare module BABYLON {
  63343. /**
  63344. * Block used to get the reciprocal (1 / x) of a value
  63345. */
  63346. export class ReciprocalBlock extends NodeMaterialBlock {
  63347. /**
  63348. * Creates a new ReciprocalBlock
  63349. * @param name defines the block name
  63350. */
  63351. constructor(name: string);
  63352. /**
  63353. * Gets the current class name
  63354. * @returns the class name
  63355. */
  63356. getClassName(): string;
  63357. /**
  63358. * Gets the input component
  63359. */
  63360. get input(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the output component
  63363. */
  63364. get output(): NodeMaterialConnectionPoint;
  63365. protected _buildBlock(state: NodeMaterialBuildState): this;
  63366. }
  63367. }
  63368. declare module BABYLON {
  63369. /**
  63370. * Block used to replace a color by another one
  63371. */
  63372. export class ReplaceColorBlock extends NodeMaterialBlock {
  63373. /**
  63374. * Creates a new ReplaceColorBlock
  63375. * @param name defines the block name
  63376. */
  63377. constructor(name: string);
  63378. /**
  63379. * Gets the current class name
  63380. * @returns the class name
  63381. */
  63382. getClassName(): string;
  63383. /**
  63384. * Gets the value input component
  63385. */
  63386. get value(): NodeMaterialConnectionPoint;
  63387. /**
  63388. * Gets the reference input component
  63389. */
  63390. get reference(): NodeMaterialConnectionPoint;
  63391. /**
  63392. * Gets the distance input component
  63393. */
  63394. get distance(): NodeMaterialConnectionPoint;
  63395. /**
  63396. * Gets the replacement input component
  63397. */
  63398. get replacement(): NodeMaterialConnectionPoint;
  63399. /**
  63400. * Gets the output component
  63401. */
  63402. get output(): NodeMaterialConnectionPoint;
  63403. protected _buildBlock(state: NodeMaterialBuildState): this;
  63404. }
  63405. }
  63406. declare module BABYLON {
  63407. /**
  63408. * Block used to posterize a value
  63409. * @see https://en.wikipedia.org/wiki/Posterization
  63410. */
  63411. export class PosterizeBlock extends NodeMaterialBlock {
  63412. /**
  63413. * Creates a new PosterizeBlock
  63414. * @param name defines the block name
  63415. */
  63416. constructor(name: string);
  63417. /**
  63418. * Gets the current class name
  63419. * @returns the class name
  63420. */
  63421. getClassName(): string;
  63422. /**
  63423. * Gets the value input component
  63424. */
  63425. get value(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the steps input component
  63428. */
  63429. get steps(): NodeMaterialConnectionPoint;
  63430. /**
  63431. * Gets the output component
  63432. */
  63433. get output(): NodeMaterialConnectionPoint;
  63434. protected _buildBlock(state: NodeMaterialBuildState): this;
  63435. }
  63436. }
  63437. declare module BABYLON {
  63438. /**
  63439. * Operations supported by the Wave block
  63440. */
  63441. export enum WaveBlockKind {
  63442. /** SawTooth */
  63443. SawTooth = 0,
  63444. /** Square */
  63445. Square = 1,
  63446. /** Triangle */
  63447. Triangle = 2
  63448. }
  63449. /**
  63450. * Block used to apply wave operation to floats
  63451. */
  63452. export class WaveBlock extends NodeMaterialBlock {
  63453. /**
  63454. * Gets or sets the kibnd of wave to be applied by the block
  63455. */
  63456. kind: WaveBlockKind;
  63457. /**
  63458. * Creates a new WaveBlock
  63459. * @param name defines the block name
  63460. */
  63461. constructor(name: string);
  63462. /**
  63463. * Gets the current class name
  63464. * @returns the class name
  63465. */
  63466. getClassName(): string;
  63467. /**
  63468. * Gets the input component
  63469. */
  63470. get input(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the output component
  63473. */
  63474. get output(): NodeMaterialConnectionPoint;
  63475. protected _buildBlock(state: NodeMaterialBuildState): this;
  63476. serialize(): any;
  63477. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63478. }
  63479. }
  63480. declare module BABYLON {
  63481. /**
  63482. * Class used to store a color step for the GradientBlock
  63483. */
  63484. export class GradientBlockColorStep {
  63485. /**
  63486. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63487. */
  63488. step: number;
  63489. /**
  63490. * Gets or sets the color associated with this step
  63491. */
  63492. color: Color3;
  63493. /**
  63494. * Creates a new GradientBlockColorStep
  63495. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63496. * @param color defines the color associated with this step
  63497. */
  63498. constructor(
  63499. /**
  63500. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63501. */
  63502. step: number,
  63503. /**
  63504. * Gets or sets the color associated with this step
  63505. */
  63506. color: Color3);
  63507. }
  63508. /**
  63509. * Block used to return a color from a gradient based on an input value between 0 and 1
  63510. */
  63511. export class GradientBlock extends NodeMaterialBlock {
  63512. /**
  63513. * Gets or sets the list of color steps
  63514. */
  63515. colorSteps: GradientBlockColorStep[];
  63516. /**
  63517. * Creates a new GradientBlock
  63518. * @param name defines the block name
  63519. */
  63520. constructor(name: string);
  63521. /**
  63522. * Gets the current class name
  63523. * @returns the class name
  63524. */
  63525. getClassName(): string;
  63526. /**
  63527. * Gets the gradient input component
  63528. */
  63529. get gradient(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the output component
  63532. */
  63533. get output(): NodeMaterialConnectionPoint;
  63534. private _writeColorConstant;
  63535. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63536. serialize(): any;
  63537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63538. protected _dumpPropertiesCode(): string;
  63539. }
  63540. }
  63541. declare module BABYLON {
  63542. /**
  63543. * Block used to normalize lerp between 2 values
  63544. */
  63545. export class NLerpBlock extends NodeMaterialBlock {
  63546. /**
  63547. * Creates a new NLerpBlock
  63548. * @param name defines the block name
  63549. */
  63550. constructor(name: string);
  63551. /**
  63552. * Gets the current class name
  63553. * @returns the class name
  63554. */
  63555. getClassName(): string;
  63556. /**
  63557. * Gets the left operand input component
  63558. */
  63559. get left(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the right operand input component
  63562. */
  63563. get right(): NodeMaterialConnectionPoint;
  63564. /**
  63565. * Gets the gradient operand input component
  63566. */
  63567. get gradient(): NodeMaterialConnectionPoint;
  63568. /**
  63569. * Gets the output component
  63570. */
  63571. get output(): NodeMaterialConnectionPoint;
  63572. protected _buildBlock(state: NodeMaterialBuildState): this;
  63573. }
  63574. }
  63575. declare module BABYLON {
  63576. /**
  63577. * block used to Generate a Worley Noise 3D Noise Pattern
  63578. */
  63579. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63580. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63581. manhattanDistance: boolean;
  63582. /**
  63583. * Creates a new WorleyNoise3DBlock
  63584. * @param name defines the block name
  63585. */
  63586. constructor(name: string);
  63587. /**
  63588. * Gets the current class name
  63589. * @returns the class name
  63590. */
  63591. getClassName(): string;
  63592. /**
  63593. * Gets the seed input component
  63594. */
  63595. get seed(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the jitter input component
  63598. */
  63599. get jitter(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the output component
  63602. */
  63603. get output(): NodeMaterialConnectionPoint;
  63604. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63605. /**
  63606. * Exposes the properties to the UI?
  63607. */
  63608. protected _dumpPropertiesCode(): string;
  63609. /**
  63610. * Exposes the properties to the Seralize?
  63611. */
  63612. serialize(): any;
  63613. /**
  63614. * Exposes the properties to the deseralize?
  63615. */
  63616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63617. }
  63618. }
  63619. declare module BABYLON {
  63620. /**
  63621. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63622. */
  63623. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63624. /**
  63625. * Creates a new SimplexPerlin3DBlock
  63626. * @param name defines the block name
  63627. */
  63628. constructor(name: string);
  63629. /**
  63630. * Gets the current class name
  63631. * @returns the class name
  63632. */
  63633. getClassName(): string;
  63634. /**
  63635. * Gets the seed operand input component
  63636. */
  63637. get seed(): NodeMaterialConnectionPoint;
  63638. /**
  63639. * Gets the output component
  63640. */
  63641. get output(): NodeMaterialConnectionPoint;
  63642. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63643. }
  63644. }
  63645. declare module BABYLON {
  63646. /**
  63647. * Block used to blend normals
  63648. */
  63649. export class NormalBlendBlock extends NodeMaterialBlock {
  63650. /**
  63651. * Creates a new NormalBlendBlock
  63652. * @param name defines the block name
  63653. */
  63654. constructor(name: string);
  63655. /**
  63656. * Gets the current class name
  63657. * @returns the class name
  63658. */
  63659. getClassName(): string;
  63660. /**
  63661. * Gets the first input component
  63662. */
  63663. get normalMap0(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the second input component
  63666. */
  63667. get normalMap1(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the output component
  63670. */
  63671. get output(): NodeMaterialConnectionPoint;
  63672. protected _buildBlock(state: NodeMaterialBuildState): this;
  63673. }
  63674. }
  63675. declare module BABYLON {
  63676. /**
  63677. * Block used to rotate a 2d vector by a given angle
  63678. */
  63679. export class Rotate2dBlock extends NodeMaterialBlock {
  63680. /**
  63681. * Creates a new Rotate2dBlock
  63682. * @param name defines the block name
  63683. */
  63684. constructor(name: string);
  63685. /**
  63686. * Gets the current class name
  63687. * @returns the class name
  63688. */
  63689. getClassName(): string;
  63690. /**
  63691. * Gets the input vector
  63692. */
  63693. get input(): NodeMaterialConnectionPoint;
  63694. /**
  63695. * Gets the input angle
  63696. */
  63697. get angle(): NodeMaterialConnectionPoint;
  63698. /**
  63699. * Gets the output component
  63700. */
  63701. get output(): NodeMaterialConnectionPoint;
  63702. autoConfigure(material: NodeMaterial): void;
  63703. protected _buildBlock(state: NodeMaterialBuildState): this;
  63704. }
  63705. }
  63706. declare module BABYLON {
  63707. /**
  63708. * Block used to get the reflected vector from a direction and a normal
  63709. */
  63710. export class ReflectBlock extends NodeMaterialBlock {
  63711. /**
  63712. * Creates a new ReflectBlock
  63713. * @param name defines the block name
  63714. */
  63715. constructor(name: string);
  63716. /**
  63717. * Gets the current class name
  63718. * @returns the class name
  63719. */
  63720. getClassName(): string;
  63721. /**
  63722. * Gets the incident component
  63723. */
  63724. get incident(): NodeMaterialConnectionPoint;
  63725. /**
  63726. * Gets the normal component
  63727. */
  63728. get normal(): NodeMaterialConnectionPoint;
  63729. /**
  63730. * Gets the output component
  63731. */
  63732. get output(): NodeMaterialConnectionPoint;
  63733. protected _buildBlock(state: NodeMaterialBuildState): this;
  63734. }
  63735. }
  63736. declare module BABYLON {
  63737. /**
  63738. * Block used to get the refracted vector from a direction and a normal
  63739. */
  63740. export class RefractBlock extends NodeMaterialBlock {
  63741. /**
  63742. * Creates a new RefractBlock
  63743. * @param name defines the block name
  63744. */
  63745. constructor(name: string);
  63746. /**
  63747. * Gets the current class name
  63748. * @returns the class name
  63749. */
  63750. getClassName(): string;
  63751. /**
  63752. * Gets the incident component
  63753. */
  63754. get incident(): NodeMaterialConnectionPoint;
  63755. /**
  63756. * Gets the normal component
  63757. */
  63758. get normal(): NodeMaterialConnectionPoint;
  63759. /**
  63760. * Gets the index of refraction component
  63761. */
  63762. get ior(): NodeMaterialConnectionPoint;
  63763. /**
  63764. * Gets the output component
  63765. */
  63766. get output(): NodeMaterialConnectionPoint;
  63767. protected _buildBlock(state: NodeMaterialBuildState): this;
  63768. }
  63769. }
  63770. declare module BABYLON {
  63771. /**
  63772. * Block used to desaturate a color
  63773. */
  63774. export class DesaturateBlock extends NodeMaterialBlock {
  63775. /**
  63776. * Creates a new DesaturateBlock
  63777. * @param name defines the block name
  63778. */
  63779. constructor(name: string);
  63780. /**
  63781. * Gets the current class name
  63782. * @returns the class name
  63783. */
  63784. getClassName(): string;
  63785. /**
  63786. * Gets the color operand input component
  63787. */
  63788. get color(): NodeMaterialConnectionPoint;
  63789. /**
  63790. * Gets the level operand input component
  63791. */
  63792. get level(): NodeMaterialConnectionPoint;
  63793. /**
  63794. * Gets the output component
  63795. */
  63796. get output(): NodeMaterialConnectionPoint;
  63797. protected _buildBlock(state: NodeMaterialBuildState): this;
  63798. }
  63799. }
  63800. declare module BABYLON {
  63801. /**
  63802. * Block used to implement the ambient occlusion module of the PBR material
  63803. */
  63804. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63805. /**
  63806. * Create a new AmbientOcclusionBlock
  63807. * @param name defines the block name
  63808. */
  63809. constructor(name: string);
  63810. /**
  63811. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63812. */
  63813. useAmbientInGrayScale: boolean;
  63814. /**
  63815. * Initialize the block and prepare the context for build
  63816. * @param state defines the state that will be used for the build
  63817. */
  63818. initialize(state: NodeMaterialBuildState): void;
  63819. /**
  63820. * Gets the current class name
  63821. * @returns the class name
  63822. */
  63823. getClassName(): string;
  63824. /**
  63825. * Gets the texture input component
  63826. */
  63827. get texture(): NodeMaterialConnectionPoint;
  63828. /**
  63829. * Gets the texture intensity component
  63830. */
  63831. get intensity(): NodeMaterialConnectionPoint;
  63832. /**
  63833. * Gets the direct light intensity input component
  63834. */
  63835. get directLightIntensity(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the ambient occlusion object output component
  63838. */
  63839. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the main code of the block (fragment side)
  63842. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63843. * @returns the shader code
  63844. */
  63845. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63847. protected _buildBlock(state: NodeMaterialBuildState): this;
  63848. protected _dumpPropertiesCode(): string;
  63849. serialize(): any;
  63850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63851. }
  63852. }
  63853. declare module BABYLON {
  63854. /**
  63855. * Block used to implement the reflection module of the PBR material
  63856. */
  63857. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63858. /** @hidden */
  63859. _defineLODReflectionAlpha: string;
  63860. /** @hidden */
  63861. _defineLinearSpecularReflection: string;
  63862. private _vEnvironmentIrradianceName;
  63863. /** @hidden */
  63864. _vReflectionMicrosurfaceInfosName: string;
  63865. /** @hidden */
  63866. _vReflectionInfosName: string;
  63867. /** @hidden */
  63868. _vReflectionFilteringInfoName: string;
  63869. private _scene;
  63870. /**
  63871. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63872. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63873. * It's less burden on the user side in the editor part.
  63874. */
  63875. /** @hidden */
  63876. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63877. /** @hidden */
  63878. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63879. /** @hidden */
  63880. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63881. /**
  63882. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63883. * diffuse part of the IBL.
  63884. */
  63885. useSphericalHarmonics: boolean;
  63886. /**
  63887. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63888. */
  63889. forceIrradianceInFragment: boolean;
  63890. /**
  63891. * Create a new ReflectionBlock
  63892. * @param name defines the block name
  63893. */
  63894. constructor(name: string);
  63895. /**
  63896. * Gets the current class name
  63897. * @returns the class name
  63898. */
  63899. getClassName(): string;
  63900. /**
  63901. * Gets the position input component
  63902. */
  63903. get position(): NodeMaterialConnectionPoint;
  63904. /**
  63905. * Gets the world position input component
  63906. */
  63907. get worldPosition(): NodeMaterialConnectionPoint;
  63908. /**
  63909. * Gets the world normal input component
  63910. */
  63911. get worldNormal(): NodeMaterialConnectionPoint;
  63912. /**
  63913. * Gets the world input component
  63914. */
  63915. get world(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the camera (or eye) position component
  63918. */
  63919. get cameraPosition(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the view input component
  63922. */
  63923. get view(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the color input component
  63926. */
  63927. get color(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the reflection object output component
  63930. */
  63931. get reflection(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63934. */
  63935. get hasTexture(): boolean;
  63936. /**
  63937. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63938. */
  63939. get reflectionColor(): string;
  63940. protected _getTexture(): Nullable<BaseTexture>;
  63941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63943. /**
  63944. * Gets the code to inject in the vertex shader
  63945. * @param state current state of the node material building
  63946. * @returns the shader code
  63947. */
  63948. handleVertexSide(state: NodeMaterialBuildState): string;
  63949. /**
  63950. * Gets the main code of the block (fragment side)
  63951. * @param state current state of the node material building
  63952. * @param normalVarName name of the existing variable corresponding to the normal
  63953. * @returns the shader code
  63954. */
  63955. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63956. protected _buildBlock(state: NodeMaterialBuildState): this;
  63957. protected _dumpPropertiesCode(): string;
  63958. serialize(): any;
  63959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63960. }
  63961. }
  63962. declare module BABYLON {
  63963. /**
  63964. * Block used to implement the sheen module of the PBR material
  63965. */
  63966. export class SheenBlock extends NodeMaterialBlock {
  63967. /**
  63968. * Create a new SheenBlock
  63969. * @param name defines the block name
  63970. */
  63971. constructor(name: string);
  63972. /**
  63973. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63974. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63975. * making it easier to setup and tweak the effect
  63976. */
  63977. albedoScaling: boolean;
  63978. /**
  63979. * Defines if the sheen is linked to the sheen color.
  63980. */
  63981. linkSheenWithAlbedo: boolean;
  63982. /**
  63983. * Initialize the block and prepare the context for build
  63984. * @param state defines the state that will be used for the build
  63985. */
  63986. initialize(state: NodeMaterialBuildState): void;
  63987. /**
  63988. * Gets the current class name
  63989. * @returns the class name
  63990. */
  63991. getClassName(): string;
  63992. /**
  63993. * Gets the intensity input component
  63994. */
  63995. get intensity(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the color input component
  63998. */
  63999. get color(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the roughness input component
  64002. */
  64003. get roughness(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the sheen object output component
  64006. */
  64007. get sheen(): NodeMaterialConnectionPoint;
  64008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64009. /**
  64010. * Gets the main code of the block (fragment side)
  64011. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64012. * @returns the shader code
  64013. */
  64014. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64015. protected _buildBlock(state: NodeMaterialBuildState): this;
  64016. protected _dumpPropertiesCode(): string;
  64017. serialize(): any;
  64018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64019. }
  64020. }
  64021. declare module BABYLON {
  64022. /**
  64023. * Block used to implement the reflectivity module of the PBR material
  64024. */
  64025. export class ReflectivityBlock extends NodeMaterialBlock {
  64026. private _metallicReflectanceColor;
  64027. private _metallicF0Factor;
  64028. /** @hidden */
  64029. _vMetallicReflectanceFactorsName: string;
  64030. /**
  64031. * The property below is set by the main PBR block prior to calling methods of this class.
  64032. */
  64033. /** @hidden */
  64034. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64035. /**
  64036. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64037. */
  64038. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64039. /**
  64040. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64041. */
  64042. useMetallnessFromMetallicTextureBlue: boolean;
  64043. /**
  64044. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64045. */
  64046. useRoughnessFromMetallicTextureAlpha: boolean;
  64047. /**
  64048. * Specifies if the metallic texture contains the roughness information in its green channel.
  64049. */
  64050. useRoughnessFromMetallicTextureGreen: boolean;
  64051. /**
  64052. * Create a new ReflectivityBlock
  64053. * @param name defines the block name
  64054. */
  64055. constructor(name: string);
  64056. /**
  64057. * Initialize the block and prepare the context for build
  64058. * @param state defines the state that will be used for the build
  64059. */
  64060. initialize(state: NodeMaterialBuildState): void;
  64061. /**
  64062. * Gets the current class name
  64063. * @returns the class name
  64064. */
  64065. getClassName(): string;
  64066. /**
  64067. * Gets the metallic input component
  64068. */
  64069. get metallic(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the roughness input component
  64072. */
  64073. get roughness(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the texture input component
  64076. */
  64077. get texture(): NodeMaterialConnectionPoint;
  64078. /**
  64079. * Gets the reflectivity object output component
  64080. */
  64081. get reflectivity(): NodeMaterialConnectionPoint;
  64082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64083. /**
  64084. * Gets the main code of the block (fragment side)
  64085. * @param state current state of the node material building
  64086. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64087. * @returns the shader code
  64088. */
  64089. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64091. protected _buildBlock(state: NodeMaterialBuildState): this;
  64092. protected _dumpPropertiesCode(): string;
  64093. serialize(): any;
  64094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Block used to implement the anisotropy module of the PBR material
  64100. */
  64101. export class AnisotropyBlock extends NodeMaterialBlock {
  64102. /**
  64103. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64104. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64105. * It's less burden on the user side in the editor part.
  64106. */
  64107. /** @hidden */
  64108. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64109. /** @hidden */
  64110. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64111. /**
  64112. * Create a new AnisotropyBlock
  64113. * @param name defines the block name
  64114. */
  64115. constructor(name: string);
  64116. /**
  64117. * Initialize the block and prepare the context for build
  64118. * @param state defines the state that will be used for the build
  64119. */
  64120. initialize(state: NodeMaterialBuildState): void;
  64121. /**
  64122. * Gets the current class name
  64123. * @returns the class name
  64124. */
  64125. getClassName(): string;
  64126. /**
  64127. * Gets the intensity input component
  64128. */
  64129. get intensity(): NodeMaterialConnectionPoint;
  64130. /**
  64131. * Gets the direction input component
  64132. */
  64133. get direction(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the texture input component
  64136. */
  64137. get texture(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the uv input component
  64140. */
  64141. get uv(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the worldTangent input component
  64144. */
  64145. get worldTangent(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the anisotropy object output component
  64148. */
  64149. get anisotropy(): NodeMaterialConnectionPoint;
  64150. private _generateTBNSpace;
  64151. /**
  64152. * Gets the main code of the block (fragment side)
  64153. * @param state current state of the node material building
  64154. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64155. * @returns the shader code
  64156. */
  64157. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64159. protected _buildBlock(state: NodeMaterialBuildState): this;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * Block used to implement the clear coat module of the PBR material
  64165. */
  64166. export class ClearCoatBlock extends NodeMaterialBlock {
  64167. private _scene;
  64168. /**
  64169. * Create a new ClearCoatBlock
  64170. * @param name defines the block name
  64171. */
  64172. constructor(name: string);
  64173. /**
  64174. * Initialize the block and prepare the context for build
  64175. * @param state defines the state that will be used for the build
  64176. */
  64177. initialize(state: NodeMaterialBuildState): void;
  64178. /**
  64179. * Gets the current class name
  64180. * @returns the class name
  64181. */
  64182. getClassName(): string;
  64183. /**
  64184. * Gets the intensity input component
  64185. */
  64186. get intensity(): NodeMaterialConnectionPoint;
  64187. /**
  64188. * Gets the roughness input component
  64189. */
  64190. get roughness(): NodeMaterialConnectionPoint;
  64191. /**
  64192. * Gets the ior input component
  64193. */
  64194. get ior(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the texture input component
  64197. */
  64198. get texture(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the bump texture input component
  64201. */
  64202. get bumpTexture(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the uv input component
  64205. */
  64206. get uv(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the tint color input component
  64209. */
  64210. get tintColor(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the tint "at distance" input component
  64213. */
  64214. get tintAtDistance(): NodeMaterialConnectionPoint;
  64215. /**
  64216. * Gets the tint thickness input component
  64217. */
  64218. get tintThickness(): NodeMaterialConnectionPoint;
  64219. /**
  64220. * Gets the world tangent input component
  64221. */
  64222. get worldTangent(): NodeMaterialConnectionPoint;
  64223. /**
  64224. * Gets the clear coat object output component
  64225. */
  64226. get clearcoat(): NodeMaterialConnectionPoint;
  64227. autoConfigure(material: NodeMaterial): void;
  64228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64230. private _generateTBNSpace;
  64231. /**
  64232. * Gets the main code of the block (fragment side)
  64233. * @param state current state of the node material building
  64234. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64235. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64236. * @param worldPosVarName name of the variable holding the world position
  64237. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64238. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64239. * @param worldNormalVarName name of the variable holding the world normal
  64240. * @returns the shader code
  64241. */
  64242. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64243. protected _buildBlock(state: NodeMaterialBuildState): this;
  64244. }
  64245. }
  64246. declare module BABYLON {
  64247. /**
  64248. * Block used to implement the sub surface module of the PBR material
  64249. */
  64250. export class SubSurfaceBlock extends NodeMaterialBlock {
  64251. /**
  64252. * Create a new SubSurfaceBlock
  64253. * @param name defines the block name
  64254. */
  64255. constructor(name: string);
  64256. /**
  64257. * Stores the intensity of the different subsurface effects in the thickness texture.
  64258. * * the green channel is the translucency intensity.
  64259. * * the blue channel is the scattering intensity.
  64260. * * the alpha channel is the refraction intensity.
  64261. */
  64262. useMaskFromThicknessTexture: boolean;
  64263. /**
  64264. * Initialize the block and prepare the context for build
  64265. * @param state defines the state that will be used for the build
  64266. */
  64267. initialize(state: NodeMaterialBuildState): void;
  64268. /**
  64269. * Gets the current class name
  64270. * @returns the class name
  64271. */
  64272. getClassName(): string;
  64273. /**
  64274. * Gets the min thickness input component
  64275. */
  64276. get minThickness(): NodeMaterialConnectionPoint;
  64277. /**
  64278. * Gets the max thickness input component
  64279. */
  64280. get maxThickness(): NodeMaterialConnectionPoint;
  64281. /**
  64282. * Gets the thickness texture component
  64283. */
  64284. get thicknessTexture(): NodeMaterialConnectionPoint;
  64285. /**
  64286. * Gets the tint color input component
  64287. */
  64288. get tintColor(): NodeMaterialConnectionPoint;
  64289. /**
  64290. * Gets the translucency intensity input component
  64291. */
  64292. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the translucency diffusion distance input component
  64295. */
  64296. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64297. /**
  64298. * Gets the refraction object parameters
  64299. */
  64300. get refraction(): NodeMaterialConnectionPoint;
  64301. /**
  64302. * Gets the sub surface object output component
  64303. */
  64304. get subsurface(): NodeMaterialConnectionPoint;
  64305. autoConfigure(material: NodeMaterial): void;
  64306. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64307. /**
  64308. * Gets the main code of the block (fragment side)
  64309. * @param state current state of the node material building
  64310. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64311. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64312. * @param worldPosVarName name of the variable holding the world position
  64313. * @returns the shader code
  64314. */
  64315. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64316. protected _buildBlock(state: NodeMaterialBuildState): this;
  64317. }
  64318. }
  64319. declare module BABYLON {
  64320. /**
  64321. * Block used to implement the PBR metallic/roughness model
  64322. */
  64323. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64324. /**
  64325. * Gets or sets the light associated with this block
  64326. */
  64327. light: Nullable<Light>;
  64328. private _lightId;
  64329. private _scene;
  64330. private _environmentBRDFTexture;
  64331. private _environmentBrdfSamplerName;
  64332. private _vNormalWName;
  64333. private _invertNormalName;
  64334. /**
  64335. * Create a new ReflectionBlock
  64336. * @param name defines the block name
  64337. */
  64338. constructor(name: string);
  64339. /**
  64340. * Intensity of the direct lights e.g. the four lights available in your scene.
  64341. * This impacts both the direct diffuse and specular highlights.
  64342. */
  64343. directIntensity: number;
  64344. /**
  64345. * Intensity of the environment e.g. how much the environment will light the object
  64346. * either through harmonics for rough material or through the refelction for shiny ones.
  64347. */
  64348. environmentIntensity: number;
  64349. /**
  64350. * This is a special control allowing the reduction of the specular highlights coming from the
  64351. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64352. */
  64353. specularIntensity: number;
  64354. /**
  64355. * Defines the falloff type used in this material.
  64356. * It by default is Physical.
  64357. */
  64358. lightFalloff: number;
  64359. /**
  64360. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64361. */
  64362. useAlphaFromAlbedoTexture: boolean;
  64363. /**
  64364. * Specifies that alpha test should be used
  64365. */
  64366. useAlphaTest: boolean;
  64367. /**
  64368. * Defines the alpha limits in alpha test mode.
  64369. */
  64370. alphaTestCutoff: number;
  64371. /**
  64372. * Specifies that alpha blending should be used
  64373. */
  64374. useAlphaBlending: boolean;
  64375. /**
  64376. * Defines if the alpha value should be determined via the rgb values.
  64377. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64378. */
  64379. opacityRGB: boolean;
  64380. /**
  64381. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64382. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64383. */
  64384. useRadianceOverAlpha: boolean;
  64385. /**
  64386. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64387. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64388. */
  64389. useSpecularOverAlpha: boolean;
  64390. /**
  64391. * Enables specular anti aliasing in the PBR shader.
  64392. * It will both interacts on the Geometry for analytical and IBL lighting.
  64393. * It also prefilter the roughness map based on the bump values.
  64394. */
  64395. enableSpecularAntiAliasing: boolean;
  64396. /**
  64397. * Enables realtime filtering on the texture.
  64398. */
  64399. realTimeFiltering: boolean;
  64400. /**
  64401. * Quality switch for realtime filtering
  64402. */
  64403. realTimeFilteringQuality: number;
  64404. /**
  64405. * Defines if the material uses energy conservation.
  64406. */
  64407. useEnergyConservation: boolean;
  64408. /**
  64409. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64410. * too much the area relying on ambient texture to define their ambient occlusion.
  64411. */
  64412. useRadianceOcclusion: boolean;
  64413. /**
  64414. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64415. * makes the reflect vector face the model (under horizon).
  64416. */
  64417. useHorizonOcclusion: boolean;
  64418. /**
  64419. * If set to true, no lighting calculations will be applied.
  64420. */
  64421. unlit: boolean;
  64422. /**
  64423. * Force normal to face away from face.
  64424. */
  64425. forceNormalForward: boolean;
  64426. /**
  64427. * Defines the material debug mode.
  64428. * It helps seeing only some components of the material while troubleshooting.
  64429. */
  64430. debugMode: number;
  64431. /**
  64432. * Specify from where on screen the debug mode should start.
  64433. * The value goes from -1 (full screen) to 1 (not visible)
  64434. * It helps with side by side comparison against the final render
  64435. * This defaults to 0
  64436. */
  64437. debugLimit: number;
  64438. /**
  64439. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64440. * You can use the factor to better multiply the final value.
  64441. */
  64442. debugFactor: number;
  64443. /**
  64444. * Initialize the block and prepare the context for build
  64445. * @param state defines the state that will be used for the build
  64446. */
  64447. initialize(state: NodeMaterialBuildState): void;
  64448. /**
  64449. * Gets the current class name
  64450. * @returns the class name
  64451. */
  64452. getClassName(): string;
  64453. /**
  64454. * Gets the world position input component
  64455. */
  64456. get worldPosition(): NodeMaterialConnectionPoint;
  64457. /**
  64458. * Gets the world normal input component
  64459. */
  64460. get worldNormal(): NodeMaterialConnectionPoint;
  64461. /**
  64462. * Gets the perturbed normal input component
  64463. */
  64464. get perturbedNormal(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the camera position input component
  64467. */
  64468. get cameraPosition(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the base color input component
  64471. */
  64472. get baseColor(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the opacity texture input component
  64475. */
  64476. get opacityTexture(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the ambient color input component
  64479. */
  64480. get ambientColor(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the reflectivity object parameters
  64483. */
  64484. get reflectivity(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the ambient occlusion object parameters
  64487. */
  64488. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the reflection object parameters
  64491. */
  64492. get reflection(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the sheen object parameters
  64495. */
  64496. get sheen(): NodeMaterialConnectionPoint;
  64497. /**
  64498. * Gets the clear coat object parameters
  64499. */
  64500. get clearcoat(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the sub surface object parameters
  64503. */
  64504. get subsurface(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the anisotropy object parameters
  64507. */
  64508. get anisotropy(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Gets the ambient output component
  64511. */
  64512. get ambient(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the diffuse output component
  64515. */
  64516. get diffuse(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the specular output component
  64519. */
  64520. get specular(): NodeMaterialConnectionPoint;
  64521. /**
  64522. * Gets the sheen output component
  64523. */
  64524. get sheenDir(): NodeMaterialConnectionPoint;
  64525. /**
  64526. * Gets the clear coat output component
  64527. */
  64528. get clearcoatDir(): NodeMaterialConnectionPoint;
  64529. /**
  64530. * Gets the indirect diffuse output component
  64531. */
  64532. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64533. /**
  64534. * Gets the indirect specular output component
  64535. */
  64536. get specularIndirect(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the indirect sheen output component
  64539. */
  64540. get sheenIndirect(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the indirect clear coat output component
  64543. */
  64544. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the refraction output component
  64547. */
  64548. get refraction(): NodeMaterialConnectionPoint;
  64549. /**
  64550. * Gets the global lighting output component
  64551. */
  64552. get lighting(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the shadow output component
  64555. */
  64556. get shadow(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the alpha output component
  64559. */
  64560. get alpha(): NodeMaterialConnectionPoint;
  64561. autoConfigure(material: NodeMaterial): void;
  64562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64563. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64565. private _injectVertexCode;
  64566. /**
  64567. * Gets the code corresponding to the albedo/opacity module
  64568. * @returns the shader code
  64569. */
  64570. getAlbedoOpacityCode(): string;
  64571. protected _buildBlock(state: NodeMaterialBuildState): this;
  64572. protected _dumpPropertiesCode(): string;
  64573. serialize(): any;
  64574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64575. }
  64576. }
  64577. declare module BABYLON {
  64578. /**
  64579. * Block used to compute value of one parameter modulo another
  64580. */
  64581. export class ModBlock extends NodeMaterialBlock {
  64582. /**
  64583. * Creates a new ModBlock
  64584. * @param name defines the block name
  64585. */
  64586. constructor(name: string);
  64587. /**
  64588. * Gets the current class name
  64589. * @returns the class name
  64590. */
  64591. getClassName(): string;
  64592. /**
  64593. * Gets the left operand input component
  64594. */
  64595. get left(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the right operand input component
  64598. */
  64599. get right(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the output component
  64602. */
  64603. get output(): NodeMaterialConnectionPoint;
  64604. protected _buildBlock(state: NodeMaterialBuildState): this;
  64605. }
  64606. }
  64607. declare module BABYLON {
  64608. /**
  64609. * Helper class to push actions to a pool of workers.
  64610. */
  64611. export class WorkerPool implements IDisposable {
  64612. private _workerInfos;
  64613. private _pendingActions;
  64614. /**
  64615. * Constructor
  64616. * @param workers Array of workers to use for actions
  64617. */
  64618. constructor(workers: Array<Worker>);
  64619. /**
  64620. * Terminates all workers and clears any pending actions.
  64621. */
  64622. dispose(): void;
  64623. /**
  64624. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64625. * pended until a worker has completed its action.
  64626. * @param action The action to perform. Call onComplete when the action is complete.
  64627. */
  64628. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64629. private _execute;
  64630. }
  64631. }
  64632. declare module BABYLON {
  64633. /**
  64634. * Configuration for Draco compression
  64635. */
  64636. export interface IDracoCompressionConfiguration {
  64637. /**
  64638. * Configuration for the decoder.
  64639. */
  64640. decoder: {
  64641. /**
  64642. * The url to the WebAssembly module.
  64643. */
  64644. wasmUrl?: string;
  64645. /**
  64646. * The url to the WebAssembly binary.
  64647. */
  64648. wasmBinaryUrl?: string;
  64649. /**
  64650. * The url to the fallback JavaScript module.
  64651. */
  64652. fallbackUrl?: string;
  64653. };
  64654. }
  64655. /**
  64656. * Draco compression (https://google.github.io/draco/)
  64657. *
  64658. * This class wraps the Draco module.
  64659. *
  64660. * **Encoder**
  64661. *
  64662. * The encoder is not currently implemented.
  64663. *
  64664. * **Decoder**
  64665. *
  64666. * 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.
  64667. *
  64668. * To update the configuration, use the following code:
  64669. * ```javascript
  64670. * DracoCompression.Configuration = {
  64671. * decoder: {
  64672. * wasmUrl: "<url to the WebAssembly library>",
  64673. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64674. * fallbackUrl: "<url to the fallback JavaScript library>",
  64675. * }
  64676. * };
  64677. * ```
  64678. *
  64679. * 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.
  64680. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64681. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64682. *
  64683. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64684. * ```javascript
  64685. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64686. * ```
  64687. *
  64688. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64689. */
  64690. export class DracoCompression implements IDisposable {
  64691. private _workerPoolPromise?;
  64692. private _decoderModulePromise?;
  64693. /**
  64694. * The configuration. Defaults to the following urls:
  64695. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64696. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64697. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64698. */
  64699. static Configuration: IDracoCompressionConfiguration;
  64700. /**
  64701. * Returns true if the decoder configuration is available.
  64702. */
  64703. static get DecoderAvailable(): boolean;
  64704. /**
  64705. * Default number of workers to create when creating the draco compression object.
  64706. */
  64707. static DefaultNumWorkers: number;
  64708. private static GetDefaultNumWorkers;
  64709. private static _Default;
  64710. /**
  64711. * Default instance for the draco compression object.
  64712. */
  64713. static get Default(): DracoCompression;
  64714. /**
  64715. * Constructor
  64716. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64717. */
  64718. constructor(numWorkers?: number);
  64719. /**
  64720. * Stop all async operations and release resources.
  64721. */
  64722. dispose(): void;
  64723. /**
  64724. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64725. * @returns a promise that resolves when ready
  64726. */
  64727. whenReadyAsync(): Promise<void>;
  64728. /**
  64729. * Decode Draco compressed mesh data to vertex data.
  64730. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64731. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64732. * @returns A promise that resolves with the decoded vertex data
  64733. */
  64734. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64735. [kind: string]: number;
  64736. }): Promise<VertexData>;
  64737. }
  64738. }
  64739. declare module BABYLON {
  64740. /**
  64741. * Class for building Constructive Solid Geometry
  64742. */
  64743. export class CSG {
  64744. private polygons;
  64745. /**
  64746. * The world matrix
  64747. */
  64748. matrix: Matrix;
  64749. /**
  64750. * Stores the position
  64751. */
  64752. position: Vector3;
  64753. /**
  64754. * Stores the rotation
  64755. */
  64756. rotation: Vector3;
  64757. /**
  64758. * Stores the rotation quaternion
  64759. */
  64760. rotationQuaternion: Nullable<Quaternion>;
  64761. /**
  64762. * Stores the scaling vector
  64763. */
  64764. scaling: Vector3;
  64765. /**
  64766. * Convert the Mesh to CSG
  64767. * @param mesh The Mesh to convert to CSG
  64768. * @returns A new CSG from the Mesh
  64769. */
  64770. static FromMesh(mesh: Mesh): CSG;
  64771. /**
  64772. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64773. * @param polygons Polygons used to construct a CSG solid
  64774. */
  64775. private static FromPolygons;
  64776. /**
  64777. * Clones, or makes a deep copy, of the CSG
  64778. * @returns A new CSG
  64779. */
  64780. clone(): CSG;
  64781. /**
  64782. * Unions this CSG with another CSG
  64783. * @param csg The CSG to union against this CSG
  64784. * @returns The unioned CSG
  64785. */
  64786. union(csg: CSG): CSG;
  64787. /**
  64788. * Unions this CSG with another CSG in place
  64789. * @param csg The CSG to union against this CSG
  64790. */
  64791. unionInPlace(csg: CSG): void;
  64792. /**
  64793. * Subtracts this CSG with another CSG
  64794. * @param csg The CSG to subtract against this CSG
  64795. * @returns A new CSG
  64796. */
  64797. subtract(csg: CSG): CSG;
  64798. /**
  64799. * Subtracts this CSG with another CSG in place
  64800. * @param csg The CSG to subtact against this CSG
  64801. */
  64802. subtractInPlace(csg: CSG): void;
  64803. /**
  64804. * Intersect this CSG with another CSG
  64805. * @param csg The CSG to intersect against this CSG
  64806. * @returns A new CSG
  64807. */
  64808. intersect(csg: CSG): CSG;
  64809. /**
  64810. * Intersects this CSG with another CSG in place
  64811. * @param csg The CSG to intersect against this CSG
  64812. */
  64813. intersectInPlace(csg: CSG): void;
  64814. /**
  64815. * Return a new CSG solid with solid and empty space switched. This solid is
  64816. * not modified.
  64817. * @returns A new CSG solid with solid and empty space switched
  64818. */
  64819. inverse(): CSG;
  64820. /**
  64821. * Inverses the CSG in place
  64822. */
  64823. inverseInPlace(): void;
  64824. /**
  64825. * This is used to keep meshes transformations so they can be restored
  64826. * when we build back a Babylon Mesh
  64827. * NB : All CSG operations are performed in world coordinates
  64828. * @param csg The CSG to copy the transform attributes from
  64829. * @returns This CSG
  64830. */
  64831. copyTransformAttributes(csg: CSG): CSG;
  64832. /**
  64833. * Build Raw mesh from CSG
  64834. * Coordinates here are in world space
  64835. * @param name The name of the mesh geometry
  64836. * @param scene The Scene
  64837. * @param keepSubMeshes Specifies if the submeshes should be kept
  64838. * @returns A new Mesh
  64839. */
  64840. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64841. /**
  64842. * Build Mesh from CSG taking material and transforms into account
  64843. * @param name The name of the Mesh
  64844. * @param material The material of the Mesh
  64845. * @param scene The Scene
  64846. * @param keepSubMeshes Specifies if submeshes should be kept
  64847. * @returns The new Mesh
  64848. */
  64849. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /**
  64854. * Class used to create a trail following a mesh
  64855. */
  64856. export class TrailMesh extends Mesh {
  64857. private _generator;
  64858. private _autoStart;
  64859. private _running;
  64860. private _diameter;
  64861. private _length;
  64862. private _sectionPolygonPointsCount;
  64863. private _sectionVectors;
  64864. private _sectionNormalVectors;
  64865. private _beforeRenderObserver;
  64866. /**
  64867. * @constructor
  64868. * @param name The value used by scene.getMeshByName() to do a lookup.
  64869. * @param generator The mesh or transform node to generate a trail.
  64870. * @param scene The scene to add this mesh to.
  64871. * @param diameter Diameter of trailing mesh. Default is 1.
  64872. * @param length Length of trailing mesh. Default is 60.
  64873. * @param autoStart Automatically start trailing mesh. Default true.
  64874. */
  64875. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64876. /**
  64877. * "TrailMesh"
  64878. * @returns "TrailMesh"
  64879. */
  64880. getClassName(): string;
  64881. private _createMesh;
  64882. /**
  64883. * Start trailing mesh.
  64884. */
  64885. start(): void;
  64886. /**
  64887. * Stop trailing mesh.
  64888. */
  64889. stop(): void;
  64890. /**
  64891. * Update trailing mesh geometry.
  64892. */
  64893. update(): void;
  64894. /**
  64895. * Returns a new TrailMesh object.
  64896. * @param name is a string, the name given to the new mesh
  64897. * @param newGenerator use new generator object for cloned trail mesh
  64898. * @returns a new mesh
  64899. */
  64900. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64901. /**
  64902. * Serializes this trail mesh
  64903. * @param serializationObject object to write serialization to
  64904. */
  64905. serialize(serializationObject: any): void;
  64906. /**
  64907. * Parses a serialized trail mesh
  64908. * @param parsedMesh the serialized mesh
  64909. * @param scene the scene to create the trail mesh in
  64910. * @returns the created trail mesh
  64911. */
  64912. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64913. }
  64914. }
  64915. declare module BABYLON {
  64916. /**
  64917. * Class containing static functions to help procedurally build meshes
  64918. */
  64919. export class TiledBoxBuilder {
  64920. /**
  64921. * Creates a box mesh
  64922. * 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)
  64923. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64925. * * 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
  64926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64927. * @param name defines the name of the mesh
  64928. * @param options defines the options used to create the mesh
  64929. * @param scene defines the hosting scene
  64930. * @returns the box mesh
  64931. */
  64932. static CreateTiledBox(name: string, options: {
  64933. pattern?: number;
  64934. width?: number;
  64935. height?: number;
  64936. depth?: number;
  64937. tileSize?: number;
  64938. tileWidth?: number;
  64939. tileHeight?: number;
  64940. alignHorizontal?: number;
  64941. alignVertical?: number;
  64942. faceUV?: Vector4[];
  64943. faceColors?: Color4[];
  64944. sideOrientation?: number;
  64945. updatable?: boolean;
  64946. }, scene?: Nullable<Scene>): Mesh;
  64947. }
  64948. }
  64949. declare module BABYLON {
  64950. /**
  64951. * Class containing static functions to help procedurally build meshes
  64952. */
  64953. export class TorusKnotBuilder {
  64954. /**
  64955. * Creates a torus knot mesh
  64956. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64957. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64958. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64959. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64961. * * 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
  64962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64963. * @param name defines the name of the mesh
  64964. * @param options defines the options used to create the mesh
  64965. * @param scene defines the hosting scene
  64966. * @returns the torus knot mesh
  64967. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64968. */
  64969. static CreateTorusKnot(name: string, options: {
  64970. radius?: number;
  64971. tube?: number;
  64972. radialSegments?: number;
  64973. tubularSegments?: number;
  64974. p?: number;
  64975. q?: number;
  64976. updatable?: boolean;
  64977. sideOrientation?: number;
  64978. frontUVs?: Vector4;
  64979. backUVs?: Vector4;
  64980. }, scene: any): Mesh;
  64981. }
  64982. }
  64983. declare module BABYLON {
  64984. /**
  64985. * Polygon
  64986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64987. */
  64988. export class Polygon {
  64989. /**
  64990. * Creates a rectangle
  64991. * @param xmin bottom X coord
  64992. * @param ymin bottom Y coord
  64993. * @param xmax top X coord
  64994. * @param ymax top Y coord
  64995. * @returns points that make the resulting rectation
  64996. */
  64997. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64998. /**
  64999. * Creates a circle
  65000. * @param radius radius of circle
  65001. * @param cx scale in x
  65002. * @param cy scale in y
  65003. * @param numberOfSides number of sides that make up the circle
  65004. * @returns points that make the resulting circle
  65005. */
  65006. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65007. /**
  65008. * Creates a polygon from input string
  65009. * @param input Input polygon data
  65010. * @returns the parsed points
  65011. */
  65012. static Parse(input: string): Vector2[];
  65013. /**
  65014. * Starts building a polygon from x and y coordinates
  65015. * @param x x coordinate
  65016. * @param y y coordinate
  65017. * @returns the started path2
  65018. */
  65019. static StartingAt(x: number, y: number): Path2;
  65020. }
  65021. /**
  65022. * Builds a polygon
  65023. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65024. */
  65025. export class PolygonMeshBuilder {
  65026. private _points;
  65027. private _outlinepoints;
  65028. private _holes;
  65029. private _name;
  65030. private _scene;
  65031. private _epoints;
  65032. private _eholes;
  65033. private _addToepoint;
  65034. /**
  65035. * Babylon reference to the earcut plugin.
  65036. */
  65037. bjsEarcut: any;
  65038. /**
  65039. * Creates a PolygonMeshBuilder
  65040. * @param name name of the builder
  65041. * @param contours Path of the polygon
  65042. * @param scene scene to add to when creating the mesh
  65043. * @param earcutInjection can be used to inject your own earcut reference
  65044. */
  65045. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65046. /**
  65047. * Adds a whole within the polygon
  65048. * @param hole Array of points defining the hole
  65049. * @returns this
  65050. */
  65051. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65052. /**
  65053. * Creates the polygon
  65054. * @param updatable If the mesh should be updatable
  65055. * @param depth The depth of the mesh created
  65056. * @returns the created mesh
  65057. */
  65058. build(updatable?: boolean, depth?: number): Mesh;
  65059. /**
  65060. * Creates the polygon
  65061. * @param depth The depth of the mesh created
  65062. * @returns the created VertexData
  65063. */
  65064. buildVertexData(depth?: number): VertexData;
  65065. /**
  65066. * Adds a side to the polygon
  65067. * @param positions points that make the polygon
  65068. * @param normals normals of the polygon
  65069. * @param uvs uvs of the polygon
  65070. * @param indices indices of the polygon
  65071. * @param bounds bounds of the polygon
  65072. * @param points points of the polygon
  65073. * @param depth depth of the polygon
  65074. * @param flip flip of the polygon
  65075. */
  65076. private addSide;
  65077. }
  65078. }
  65079. declare module BABYLON {
  65080. /**
  65081. * Class containing static functions to help procedurally build meshes
  65082. */
  65083. export class PolygonBuilder {
  65084. /**
  65085. * Creates a polygon mesh
  65086. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65087. * * 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
  65088. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65090. * * 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)
  65091. * * Remember you can only change the shape positions, not their number when updating a polygon
  65092. * @param name defines the name of the mesh
  65093. * @param options defines the options used to create the mesh
  65094. * @param scene defines the hosting scene
  65095. * @param earcutInjection can be used to inject your own earcut reference
  65096. * @returns the polygon mesh
  65097. */
  65098. static CreatePolygon(name: string, options: {
  65099. shape: Vector3[];
  65100. holes?: Vector3[][];
  65101. depth?: number;
  65102. faceUV?: Vector4[];
  65103. faceColors?: Color4[];
  65104. updatable?: boolean;
  65105. sideOrientation?: number;
  65106. frontUVs?: Vector4;
  65107. backUVs?: Vector4;
  65108. wrap?: boolean;
  65109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65110. /**
  65111. * Creates an extruded polygon mesh, with depth in the Y direction.
  65112. * * 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)
  65113. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65114. * @param name defines the name of the mesh
  65115. * @param options defines the options used to create the mesh
  65116. * @param scene defines the hosting scene
  65117. * @param earcutInjection can be used to inject your own earcut reference
  65118. * @returns the polygon mesh
  65119. */
  65120. static ExtrudePolygon(name: string, options: {
  65121. shape: Vector3[];
  65122. holes?: Vector3[][];
  65123. depth?: number;
  65124. faceUV?: Vector4[];
  65125. faceColors?: Color4[];
  65126. updatable?: boolean;
  65127. sideOrientation?: number;
  65128. frontUVs?: Vector4;
  65129. backUVs?: Vector4;
  65130. wrap?: boolean;
  65131. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65132. }
  65133. }
  65134. declare module BABYLON {
  65135. /**
  65136. * Class containing static functions to help procedurally build meshes
  65137. */
  65138. export class LatheBuilder {
  65139. /**
  65140. * Creates lathe mesh.
  65141. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65142. * * 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
  65143. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65144. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65145. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65146. * * 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
  65147. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65148. * * 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
  65149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65150. * * 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
  65151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65153. * @param name defines the name of the mesh
  65154. * @param options defines the options used to create the mesh
  65155. * @param scene defines the hosting scene
  65156. * @returns the lathe mesh
  65157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65158. */
  65159. static CreateLathe(name: string, options: {
  65160. shape: Vector3[];
  65161. radius?: number;
  65162. tessellation?: number;
  65163. clip?: number;
  65164. arc?: number;
  65165. closed?: boolean;
  65166. updatable?: boolean;
  65167. sideOrientation?: number;
  65168. frontUVs?: Vector4;
  65169. backUVs?: Vector4;
  65170. cap?: number;
  65171. invertUV?: boolean;
  65172. }, scene?: Nullable<Scene>): Mesh;
  65173. }
  65174. }
  65175. declare module BABYLON {
  65176. /**
  65177. * Class containing static functions to help procedurally build meshes
  65178. */
  65179. export class TiledPlaneBuilder {
  65180. /**
  65181. * Creates a tiled plane mesh
  65182. * * The parameter `pattern` will, depending on value, do nothing or
  65183. * * * flip (reflect about central vertical) alternate tiles across and up
  65184. * * * flip every tile on alternate rows
  65185. * * * rotate (180 degs) alternate tiles across and up
  65186. * * * rotate every tile on alternate rows
  65187. * * * flip and rotate alternate tiles across and up
  65188. * * * flip and rotate every tile on alternate rows
  65189. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65190. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65191. * * 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
  65192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65193. * * 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)
  65194. * * 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)
  65195. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65196. * @param name defines the name of the mesh
  65197. * @param options defines the options used to create the mesh
  65198. * @param scene defines the hosting scene
  65199. * @returns the box mesh
  65200. */
  65201. static CreateTiledPlane(name: string, options: {
  65202. pattern?: number;
  65203. tileSize?: number;
  65204. tileWidth?: number;
  65205. tileHeight?: number;
  65206. size?: number;
  65207. width?: number;
  65208. height?: number;
  65209. alignHorizontal?: number;
  65210. alignVertical?: number;
  65211. sideOrientation?: number;
  65212. frontUVs?: Vector4;
  65213. backUVs?: Vector4;
  65214. updatable?: boolean;
  65215. }, scene?: Nullable<Scene>): Mesh;
  65216. }
  65217. }
  65218. declare module BABYLON {
  65219. /**
  65220. * Class containing static functions to help procedurally build meshes
  65221. */
  65222. export class TubeBuilder {
  65223. /**
  65224. * Creates a tube mesh.
  65225. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65226. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65227. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65228. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65229. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65230. * * 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)
  65231. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65232. * * 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
  65233. * * 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
  65234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65235. * * 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
  65236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65238. * @param name defines the name of the mesh
  65239. * @param options defines the options used to create the mesh
  65240. * @param scene defines the hosting scene
  65241. * @returns the tube mesh
  65242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65243. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65244. */
  65245. static CreateTube(name: string, options: {
  65246. path: Vector3[];
  65247. radius?: number;
  65248. tessellation?: number;
  65249. radiusFunction?: {
  65250. (i: number, distance: number): number;
  65251. };
  65252. cap?: number;
  65253. arc?: number;
  65254. updatable?: boolean;
  65255. sideOrientation?: number;
  65256. frontUVs?: Vector4;
  65257. backUVs?: Vector4;
  65258. instance?: Mesh;
  65259. invertUV?: boolean;
  65260. }, scene?: Nullable<Scene>): Mesh;
  65261. }
  65262. }
  65263. declare module BABYLON {
  65264. /**
  65265. * Class containing static functions to help procedurally build meshes
  65266. */
  65267. export class IcoSphereBuilder {
  65268. /**
  65269. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65270. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65271. * * 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`)
  65272. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65273. * * 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
  65274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65275. * * 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
  65276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65277. * @param name defines the name of the mesh
  65278. * @param options defines the options used to create the mesh
  65279. * @param scene defines the hosting scene
  65280. * @returns the icosahedron mesh
  65281. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65282. */
  65283. static CreateIcoSphere(name: string, options: {
  65284. radius?: number;
  65285. radiusX?: number;
  65286. radiusY?: number;
  65287. radiusZ?: number;
  65288. flat?: boolean;
  65289. subdivisions?: number;
  65290. sideOrientation?: number;
  65291. frontUVs?: Vector4;
  65292. backUVs?: Vector4;
  65293. updatable?: boolean;
  65294. }, scene?: Nullable<Scene>): Mesh;
  65295. }
  65296. }
  65297. declare module BABYLON {
  65298. /**
  65299. * Class containing static functions to help procedurally build meshes
  65300. */
  65301. export class DecalBuilder {
  65302. /**
  65303. * Creates a decal mesh.
  65304. * 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
  65305. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65306. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65307. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65308. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65309. * @param name defines the name of the mesh
  65310. * @param sourceMesh defines the mesh where the decal must be applied
  65311. * @param options defines the options used to create the mesh
  65312. * @param scene defines the hosting scene
  65313. * @returns the decal mesh
  65314. * @see https://doc.babylonjs.com/how_to/decals
  65315. */
  65316. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65317. position?: Vector3;
  65318. normal?: Vector3;
  65319. size?: Vector3;
  65320. angle?: number;
  65321. }): Mesh;
  65322. }
  65323. }
  65324. declare module BABYLON {
  65325. /**
  65326. * Class containing static functions to help procedurally build meshes
  65327. */
  65328. export class MeshBuilder {
  65329. /**
  65330. * Creates a box mesh
  65331. * * The parameter `size` sets the size (float) of each box side (default 1)
  65332. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65333. * * 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)
  65334. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65336. * * 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
  65337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65338. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65339. * @param name defines the name of the mesh
  65340. * @param options defines the options used to create the mesh
  65341. * @param scene defines the hosting scene
  65342. * @returns the box mesh
  65343. */
  65344. static CreateBox(name: string, options: {
  65345. size?: number;
  65346. width?: number;
  65347. height?: number;
  65348. depth?: number;
  65349. faceUV?: Vector4[];
  65350. faceColors?: Color4[];
  65351. sideOrientation?: number;
  65352. frontUVs?: Vector4;
  65353. backUVs?: Vector4;
  65354. wrap?: boolean;
  65355. topBaseAt?: number;
  65356. bottomBaseAt?: number;
  65357. updatable?: boolean;
  65358. }, scene?: Nullable<Scene>): Mesh;
  65359. /**
  65360. * Creates a tiled box mesh
  65361. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65363. * @param name defines the name of the mesh
  65364. * @param options defines the options used to create the mesh
  65365. * @param scene defines the hosting scene
  65366. * @returns the tiled box mesh
  65367. */
  65368. static CreateTiledBox(name: string, options: {
  65369. pattern?: number;
  65370. size?: number;
  65371. width?: number;
  65372. height?: number;
  65373. depth: number;
  65374. tileSize?: number;
  65375. tileWidth?: number;
  65376. tileHeight?: number;
  65377. faceUV?: Vector4[];
  65378. faceColors?: Color4[];
  65379. alignHorizontal?: number;
  65380. alignVertical?: number;
  65381. sideOrientation?: number;
  65382. updatable?: boolean;
  65383. }, scene?: Nullable<Scene>): Mesh;
  65384. /**
  65385. * Creates a sphere mesh
  65386. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65387. * * 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`)
  65388. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65389. * * 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
  65390. * * 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)
  65391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65392. * * 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
  65393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65394. * @param name defines the name of the mesh
  65395. * @param options defines the options used to create the mesh
  65396. * @param scene defines the hosting scene
  65397. * @returns the sphere mesh
  65398. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65399. */
  65400. static CreateSphere(name: string, options: {
  65401. segments?: number;
  65402. diameter?: number;
  65403. diameterX?: number;
  65404. diameterY?: number;
  65405. diameterZ?: number;
  65406. arc?: number;
  65407. slice?: number;
  65408. sideOrientation?: number;
  65409. frontUVs?: Vector4;
  65410. backUVs?: Vector4;
  65411. updatable?: boolean;
  65412. }, scene?: Nullable<Scene>): Mesh;
  65413. /**
  65414. * Creates a plane polygonal mesh. By default, this is a disc
  65415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65416. * * 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
  65417. * * 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
  65418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65419. * * 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
  65420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65421. * @param name defines the name of the mesh
  65422. * @param options defines the options used to create the mesh
  65423. * @param scene defines the hosting scene
  65424. * @returns the plane polygonal mesh
  65425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65426. */
  65427. static CreateDisc(name: string, options: {
  65428. radius?: number;
  65429. tessellation?: number;
  65430. arc?: number;
  65431. updatable?: boolean;
  65432. sideOrientation?: number;
  65433. frontUVs?: Vector4;
  65434. backUVs?: Vector4;
  65435. }, scene?: Nullable<Scene>): Mesh;
  65436. /**
  65437. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65438. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65439. * * 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`)
  65440. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65441. * * 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
  65442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65443. * * 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
  65444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65445. * @param name defines the name of the mesh
  65446. * @param options defines the options used to create the mesh
  65447. * @param scene defines the hosting scene
  65448. * @returns the icosahedron mesh
  65449. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65450. */
  65451. static CreateIcoSphere(name: string, options: {
  65452. radius?: number;
  65453. radiusX?: number;
  65454. radiusY?: number;
  65455. radiusZ?: number;
  65456. flat?: boolean;
  65457. subdivisions?: number;
  65458. sideOrientation?: number;
  65459. frontUVs?: Vector4;
  65460. backUVs?: Vector4;
  65461. updatable?: boolean;
  65462. }, scene?: Nullable<Scene>): Mesh;
  65463. /**
  65464. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65465. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65466. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65467. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65468. * * 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
  65469. * * 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
  65470. * * 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
  65471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65472. * * 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
  65473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65474. * * 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
  65475. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65476. * * 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
  65477. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65479. * @param name defines the name of the mesh
  65480. * @param options defines the options used to create the mesh
  65481. * @param scene defines the hosting scene
  65482. * @returns the ribbon mesh
  65483. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65485. */
  65486. static CreateRibbon(name: string, options: {
  65487. pathArray: Vector3[][];
  65488. closeArray?: boolean;
  65489. closePath?: boolean;
  65490. offset?: number;
  65491. updatable?: boolean;
  65492. sideOrientation?: number;
  65493. frontUVs?: Vector4;
  65494. backUVs?: Vector4;
  65495. instance?: Mesh;
  65496. invertUV?: boolean;
  65497. uvs?: Vector2[];
  65498. colors?: Color4[];
  65499. }, scene?: Nullable<Scene>): Mesh;
  65500. /**
  65501. * Creates a cylinder or a cone mesh
  65502. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65503. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65504. * * 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.
  65505. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65506. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65507. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65508. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65509. * * 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).
  65510. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65511. * * 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).
  65512. * * 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
  65513. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65514. * * 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
  65515. * * 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.
  65516. * * If `enclose` is false, a ring surface is one element.
  65517. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65518. * * 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
  65519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65520. * * 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
  65521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65522. * @param name defines the name of the mesh
  65523. * @param options defines the options used to create the mesh
  65524. * @param scene defines the hosting scene
  65525. * @returns the cylinder mesh
  65526. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65527. */
  65528. static CreateCylinder(name: string, options: {
  65529. height?: number;
  65530. diameterTop?: number;
  65531. diameterBottom?: number;
  65532. diameter?: number;
  65533. tessellation?: number;
  65534. subdivisions?: number;
  65535. arc?: number;
  65536. faceColors?: Color4[];
  65537. faceUV?: Vector4[];
  65538. updatable?: boolean;
  65539. hasRings?: boolean;
  65540. enclose?: boolean;
  65541. cap?: number;
  65542. sideOrientation?: number;
  65543. frontUVs?: Vector4;
  65544. backUVs?: Vector4;
  65545. }, scene?: Nullable<Scene>): Mesh;
  65546. /**
  65547. * Creates a torus mesh
  65548. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65549. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65550. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65552. * * 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
  65553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65554. * @param name defines the name of the mesh
  65555. * @param options defines the options used to create the mesh
  65556. * @param scene defines the hosting scene
  65557. * @returns the torus mesh
  65558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65559. */
  65560. static CreateTorus(name: string, options: {
  65561. diameter?: number;
  65562. thickness?: number;
  65563. tessellation?: number;
  65564. updatable?: boolean;
  65565. sideOrientation?: number;
  65566. frontUVs?: Vector4;
  65567. backUVs?: Vector4;
  65568. }, scene?: Nullable<Scene>): Mesh;
  65569. /**
  65570. * Creates a torus knot mesh
  65571. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65572. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65573. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65574. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65576. * * 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
  65577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65578. * @param name defines the name of the mesh
  65579. * @param options defines the options used to create the mesh
  65580. * @param scene defines the hosting scene
  65581. * @returns the torus knot mesh
  65582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65583. */
  65584. static CreateTorusKnot(name: string, options: {
  65585. radius?: number;
  65586. tube?: number;
  65587. radialSegments?: number;
  65588. tubularSegments?: number;
  65589. p?: number;
  65590. q?: number;
  65591. updatable?: boolean;
  65592. sideOrientation?: number;
  65593. frontUVs?: Vector4;
  65594. backUVs?: Vector4;
  65595. }, scene?: Nullable<Scene>): Mesh;
  65596. /**
  65597. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65598. * * 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
  65599. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65600. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65601. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65602. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65603. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65604. * * 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
  65605. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65608. * @param name defines the name of the new line system
  65609. * @param options defines the options used to create the line system
  65610. * @param scene defines the hosting scene
  65611. * @returns a new line system mesh
  65612. */
  65613. static CreateLineSystem(name: string, options: {
  65614. lines: Vector3[][];
  65615. updatable?: boolean;
  65616. instance?: Nullable<LinesMesh>;
  65617. colors?: Nullable<Color4[][]>;
  65618. useVertexAlpha?: boolean;
  65619. }, scene: Nullable<Scene>): LinesMesh;
  65620. /**
  65621. * Creates a line mesh
  65622. * 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
  65623. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65624. * * The parameter `points` is an array successive Vector3
  65625. * * 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
  65626. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65627. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65628. * * When updating an instance, remember that only point positions can change, not the number of points
  65629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65631. * @param name defines the name of the new line system
  65632. * @param options defines the options used to create the line system
  65633. * @param scene defines the hosting scene
  65634. * @returns a new line mesh
  65635. */
  65636. static CreateLines(name: string, options: {
  65637. points: Vector3[];
  65638. updatable?: boolean;
  65639. instance?: Nullable<LinesMesh>;
  65640. colors?: Color4[];
  65641. useVertexAlpha?: boolean;
  65642. }, scene?: Nullable<Scene>): LinesMesh;
  65643. /**
  65644. * Creates a dashed line mesh
  65645. * * 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
  65646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65647. * * The parameter `points` is an array successive Vector3
  65648. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65649. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65650. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65651. * * 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
  65652. * * When updating an instance, remember that only point positions can change, not the number of points
  65653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65654. * @param name defines the name of the mesh
  65655. * @param options defines the options used to create the mesh
  65656. * @param scene defines the hosting scene
  65657. * @returns the dashed line mesh
  65658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65659. */
  65660. static CreateDashedLines(name: string, options: {
  65661. points: Vector3[];
  65662. dashSize?: number;
  65663. gapSize?: number;
  65664. dashNb?: number;
  65665. updatable?: boolean;
  65666. instance?: LinesMesh;
  65667. }, scene?: Nullable<Scene>): LinesMesh;
  65668. /**
  65669. * 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.
  65670. * * 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.
  65671. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65672. * * 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.
  65673. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65674. * * 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
  65675. * * 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
  65676. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65678. * * 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
  65679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65681. * @param name defines the name of the mesh
  65682. * @param options defines the options used to create the mesh
  65683. * @param scene defines the hosting scene
  65684. * @returns the extruded shape mesh
  65685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65687. */
  65688. static ExtrudeShape(name: string, options: {
  65689. shape: Vector3[];
  65690. path: Vector3[];
  65691. scale?: number;
  65692. rotation?: number;
  65693. cap?: number;
  65694. updatable?: boolean;
  65695. sideOrientation?: number;
  65696. frontUVs?: Vector4;
  65697. backUVs?: Vector4;
  65698. instance?: Mesh;
  65699. invertUV?: boolean;
  65700. }, scene?: Nullable<Scene>): Mesh;
  65701. /**
  65702. * Creates an custom extruded shape mesh.
  65703. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65704. * * 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.
  65705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65706. * * 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
  65707. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65708. * * 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
  65709. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65710. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65711. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65712. * * 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
  65713. * * 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
  65714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65716. * * 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
  65717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65719. * @param name defines the name of the mesh
  65720. * @param options defines the options used to create the mesh
  65721. * @param scene defines the hosting scene
  65722. * @returns the custom extruded shape mesh
  65723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65726. */
  65727. static ExtrudeShapeCustom(name: string, options: {
  65728. shape: Vector3[];
  65729. path: Vector3[];
  65730. scaleFunction?: any;
  65731. rotationFunction?: any;
  65732. ribbonCloseArray?: boolean;
  65733. ribbonClosePath?: boolean;
  65734. cap?: number;
  65735. updatable?: boolean;
  65736. sideOrientation?: number;
  65737. frontUVs?: Vector4;
  65738. backUVs?: Vector4;
  65739. instance?: Mesh;
  65740. invertUV?: boolean;
  65741. }, scene?: Nullable<Scene>): Mesh;
  65742. /**
  65743. * Creates lathe mesh.
  65744. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65745. * * 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
  65746. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65747. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65748. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65749. * * 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
  65750. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65751. * * 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
  65752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65753. * * 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
  65754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65756. * @param name defines the name of the mesh
  65757. * @param options defines the options used to create the mesh
  65758. * @param scene defines the hosting scene
  65759. * @returns the lathe mesh
  65760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65761. */
  65762. static CreateLathe(name: string, options: {
  65763. shape: Vector3[];
  65764. radius?: number;
  65765. tessellation?: number;
  65766. clip?: number;
  65767. arc?: number;
  65768. closed?: boolean;
  65769. updatable?: boolean;
  65770. sideOrientation?: number;
  65771. frontUVs?: Vector4;
  65772. backUVs?: Vector4;
  65773. cap?: number;
  65774. invertUV?: boolean;
  65775. }, scene?: Nullable<Scene>): Mesh;
  65776. /**
  65777. * Creates a tiled plane mesh
  65778. * * You can set a limited pattern arrangement with the tiles
  65779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65780. * * 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
  65781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65782. * @param name defines the name of the mesh
  65783. * @param options defines the options used to create the mesh
  65784. * @param scene defines the hosting scene
  65785. * @returns the plane mesh
  65786. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65787. */
  65788. static CreateTiledPlane(name: string, options: {
  65789. pattern?: number;
  65790. tileSize?: number;
  65791. tileWidth?: number;
  65792. tileHeight?: number;
  65793. size?: number;
  65794. width?: number;
  65795. height?: number;
  65796. alignHorizontal?: number;
  65797. alignVertical?: number;
  65798. sideOrientation?: number;
  65799. frontUVs?: Vector4;
  65800. backUVs?: Vector4;
  65801. updatable?: boolean;
  65802. }, scene?: Nullable<Scene>): Mesh;
  65803. /**
  65804. * Creates a plane mesh
  65805. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65806. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65807. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65809. * * 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
  65810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65811. * @param name defines the name of the mesh
  65812. * @param options defines the options used to create the mesh
  65813. * @param scene defines the hosting scene
  65814. * @returns the plane mesh
  65815. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65816. */
  65817. static CreatePlane(name: string, options: {
  65818. size?: number;
  65819. width?: number;
  65820. height?: number;
  65821. sideOrientation?: number;
  65822. frontUVs?: Vector4;
  65823. backUVs?: Vector4;
  65824. updatable?: boolean;
  65825. sourcePlane?: Plane;
  65826. }, scene?: Nullable<Scene>): Mesh;
  65827. /**
  65828. * Creates a ground mesh
  65829. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65830. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65832. * @param name defines the name of the mesh
  65833. * @param options defines the options used to create the mesh
  65834. * @param scene defines the hosting scene
  65835. * @returns the ground mesh
  65836. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65837. */
  65838. static CreateGround(name: string, options: {
  65839. width?: number;
  65840. height?: number;
  65841. subdivisions?: number;
  65842. subdivisionsX?: number;
  65843. subdivisionsY?: number;
  65844. updatable?: boolean;
  65845. }, scene?: Nullable<Scene>): Mesh;
  65846. /**
  65847. * Creates a tiled ground mesh
  65848. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65849. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65850. * * 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
  65851. * * 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
  65852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65853. * @param name defines the name of the mesh
  65854. * @param options defines the options used to create the mesh
  65855. * @param scene defines the hosting scene
  65856. * @returns the tiled ground mesh
  65857. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65858. */
  65859. static CreateTiledGround(name: string, options: {
  65860. xmin: number;
  65861. zmin: number;
  65862. xmax: number;
  65863. zmax: number;
  65864. subdivisions?: {
  65865. w: number;
  65866. h: number;
  65867. };
  65868. precision?: {
  65869. w: number;
  65870. h: number;
  65871. };
  65872. updatable?: boolean;
  65873. }, scene?: Nullable<Scene>): Mesh;
  65874. /**
  65875. * Creates a ground mesh from a height map
  65876. * * The parameter `url` sets the URL of the height map image resource.
  65877. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65878. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65879. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65880. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65881. * * 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.
  65882. * * 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).
  65883. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65885. * @param name defines the name of the mesh
  65886. * @param url defines the url to the height map
  65887. * @param options defines the options used to create the mesh
  65888. * @param scene defines the hosting scene
  65889. * @returns the ground mesh
  65890. * @see https://doc.babylonjs.com/babylon101/height_map
  65891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65892. */
  65893. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65894. width?: number;
  65895. height?: number;
  65896. subdivisions?: number;
  65897. minHeight?: number;
  65898. maxHeight?: number;
  65899. colorFilter?: Color3;
  65900. alphaFilter?: number;
  65901. updatable?: boolean;
  65902. onReady?: (mesh: GroundMesh) => void;
  65903. }, scene?: Nullable<Scene>): GroundMesh;
  65904. /**
  65905. * Creates a polygon mesh
  65906. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65907. * * 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
  65908. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65910. * * 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)
  65911. * * Remember you can only change the shape positions, not their number when updating a polygon
  65912. * @param name defines the name of the mesh
  65913. * @param options defines the options used to create the mesh
  65914. * @param scene defines the hosting scene
  65915. * @param earcutInjection can be used to inject your own earcut reference
  65916. * @returns the polygon mesh
  65917. */
  65918. static CreatePolygon(name: string, options: {
  65919. shape: Vector3[];
  65920. holes?: Vector3[][];
  65921. depth?: number;
  65922. faceUV?: Vector4[];
  65923. faceColors?: Color4[];
  65924. updatable?: boolean;
  65925. sideOrientation?: number;
  65926. frontUVs?: Vector4;
  65927. backUVs?: Vector4;
  65928. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65929. /**
  65930. * Creates an extruded polygon mesh, with depth in the Y direction.
  65931. * * 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)
  65932. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65933. * @param name defines the name of the mesh
  65934. * @param options defines the options used to create the mesh
  65935. * @param scene defines the hosting scene
  65936. * @param earcutInjection can be used to inject your own earcut reference
  65937. * @returns the polygon mesh
  65938. */
  65939. static ExtrudePolygon(name: string, options: {
  65940. shape: Vector3[];
  65941. holes?: Vector3[][];
  65942. depth?: number;
  65943. faceUV?: Vector4[];
  65944. faceColors?: Color4[];
  65945. updatable?: boolean;
  65946. sideOrientation?: number;
  65947. frontUVs?: Vector4;
  65948. backUVs?: Vector4;
  65949. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65950. /**
  65951. * Creates a tube mesh.
  65952. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65953. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65954. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65955. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65956. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65957. * * 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)
  65958. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65959. * * 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
  65960. * * 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
  65961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65962. * * 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
  65963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65965. * @param name defines the name of the mesh
  65966. * @param options defines the options used to create the mesh
  65967. * @param scene defines the hosting scene
  65968. * @returns the tube mesh
  65969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65970. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65971. */
  65972. static CreateTube(name: string, options: {
  65973. path: Vector3[];
  65974. radius?: number;
  65975. tessellation?: number;
  65976. radiusFunction?: {
  65977. (i: number, distance: number): number;
  65978. };
  65979. cap?: number;
  65980. arc?: number;
  65981. updatable?: boolean;
  65982. sideOrientation?: number;
  65983. frontUVs?: Vector4;
  65984. backUVs?: Vector4;
  65985. instance?: Mesh;
  65986. invertUV?: boolean;
  65987. }, scene?: Nullable<Scene>): Mesh;
  65988. /**
  65989. * Creates a polyhedron mesh
  65990. * * 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
  65991. * * The parameter `size` (positive float, default 1) sets the polygon size
  65992. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65993. * * 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`
  65994. * * 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
  65995. * * 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)`)
  65996. * * 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
  65997. * * 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
  65998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65999. * * 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
  66000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66001. * @param name defines the name of the mesh
  66002. * @param options defines the options used to create the mesh
  66003. * @param scene defines the hosting scene
  66004. * @returns the polyhedron mesh
  66005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66006. */
  66007. static CreatePolyhedron(name: string, options: {
  66008. type?: number;
  66009. size?: number;
  66010. sizeX?: number;
  66011. sizeY?: number;
  66012. sizeZ?: number;
  66013. custom?: any;
  66014. faceUV?: Vector4[];
  66015. faceColors?: Color4[];
  66016. flat?: boolean;
  66017. updatable?: boolean;
  66018. sideOrientation?: number;
  66019. frontUVs?: Vector4;
  66020. backUVs?: Vector4;
  66021. }, scene?: Nullable<Scene>): Mesh;
  66022. /**
  66023. * Creates a decal mesh.
  66024. * 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
  66025. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66026. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66027. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66028. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66029. * @param name defines the name of the mesh
  66030. * @param sourceMesh defines the mesh where the decal must be applied
  66031. * @param options defines the options used to create the mesh
  66032. * @param scene defines the hosting scene
  66033. * @returns the decal mesh
  66034. * @see https://doc.babylonjs.com/how_to/decals
  66035. */
  66036. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66037. position?: Vector3;
  66038. normal?: Vector3;
  66039. size?: Vector3;
  66040. angle?: number;
  66041. }): Mesh;
  66042. }
  66043. }
  66044. declare module BABYLON {
  66045. /**
  66046. * A simplifier interface for future simplification implementations
  66047. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66048. */
  66049. export interface ISimplifier {
  66050. /**
  66051. * Simplification of a given mesh according to the given settings.
  66052. * Since this requires computation, it is assumed that the function runs async.
  66053. * @param settings The settings of the simplification, including quality and distance
  66054. * @param successCallback A callback that will be called after the mesh was simplified.
  66055. * @param errorCallback in case of an error, this callback will be called. optional.
  66056. */
  66057. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66058. }
  66059. /**
  66060. * Expected simplification settings.
  66061. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66062. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66063. */
  66064. export interface ISimplificationSettings {
  66065. /**
  66066. * Gets or sets the expected quality
  66067. */
  66068. quality: number;
  66069. /**
  66070. * Gets or sets the distance when this optimized version should be used
  66071. */
  66072. distance: number;
  66073. /**
  66074. * Gets an already optimized mesh
  66075. */
  66076. optimizeMesh?: boolean;
  66077. }
  66078. /**
  66079. * Class used to specify simplification options
  66080. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66081. */
  66082. export class SimplificationSettings implements ISimplificationSettings {
  66083. /** expected quality */
  66084. quality: number;
  66085. /** distance when this optimized version should be used */
  66086. distance: number;
  66087. /** already optimized mesh */
  66088. optimizeMesh?: boolean | undefined;
  66089. /**
  66090. * Creates a SimplificationSettings
  66091. * @param quality expected quality
  66092. * @param distance distance when this optimized version should be used
  66093. * @param optimizeMesh already optimized mesh
  66094. */
  66095. constructor(
  66096. /** expected quality */
  66097. quality: number,
  66098. /** distance when this optimized version should be used */
  66099. distance: number,
  66100. /** already optimized mesh */
  66101. optimizeMesh?: boolean | undefined);
  66102. }
  66103. /**
  66104. * Interface used to define a simplification task
  66105. */
  66106. export interface ISimplificationTask {
  66107. /**
  66108. * Array of settings
  66109. */
  66110. settings: Array<ISimplificationSettings>;
  66111. /**
  66112. * Simplification type
  66113. */
  66114. simplificationType: SimplificationType;
  66115. /**
  66116. * Mesh to simplify
  66117. */
  66118. mesh: Mesh;
  66119. /**
  66120. * Callback called on success
  66121. */
  66122. successCallback?: () => void;
  66123. /**
  66124. * Defines if parallel processing can be used
  66125. */
  66126. parallelProcessing: boolean;
  66127. }
  66128. /**
  66129. * Queue used to order the simplification tasks
  66130. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66131. */
  66132. export class SimplificationQueue {
  66133. private _simplificationArray;
  66134. /**
  66135. * Gets a boolean indicating that the process is still running
  66136. */
  66137. running: boolean;
  66138. /**
  66139. * Creates a new queue
  66140. */
  66141. constructor();
  66142. /**
  66143. * Adds a new simplification task
  66144. * @param task defines a task to add
  66145. */
  66146. addTask(task: ISimplificationTask): void;
  66147. /**
  66148. * Execute next task
  66149. */
  66150. executeNext(): void;
  66151. /**
  66152. * Execute a simplification task
  66153. * @param task defines the task to run
  66154. */
  66155. runSimplification(task: ISimplificationTask): void;
  66156. private getSimplifier;
  66157. }
  66158. /**
  66159. * The implemented types of simplification
  66160. * At the moment only Quadratic Error Decimation is implemented
  66161. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66162. */
  66163. export enum SimplificationType {
  66164. /** Quadratic error decimation */
  66165. QUADRATIC = 0
  66166. }
  66167. /**
  66168. * An implementation of the Quadratic Error simplification algorithm.
  66169. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66170. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66171. * @author RaananW
  66172. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66173. */
  66174. export class QuadraticErrorSimplification implements ISimplifier {
  66175. private _mesh;
  66176. private triangles;
  66177. private vertices;
  66178. private references;
  66179. private _reconstructedMesh;
  66180. /** Gets or sets the number pf sync interations */
  66181. syncIterations: number;
  66182. /** Gets or sets the aggressiveness of the simplifier */
  66183. aggressiveness: number;
  66184. /** Gets or sets the number of allowed iterations for decimation */
  66185. decimationIterations: number;
  66186. /** Gets or sets the espilon to use for bounding box computation */
  66187. boundingBoxEpsilon: number;
  66188. /**
  66189. * Creates a new QuadraticErrorSimplification
  66190. * @param _mesh defines the target mesh
  66191. */
  66192. constructor(_mesh: Mesh);
  66193. /**
  66194. * Simplification of a given mesh according to the given settings.
  66195. * Since this requires computation, it is assumed that the function runs async.
  66196. * @param settings The settings of the simplification, including quality and distance
  66197. * @param successCallback A callback that will be called after the mesh was simplified.
  66198. */
  66199. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66200. private runDecimation;
  66201. private initWithMesh;
  66202. private init;
  66203. private reconstructMesh;
  66204. private initDecimatedMesh;
  66205. private isFlipped;
  66206. private updateTriangles;
  66207. private identifyBorder;
  66208. private updateMesh;
  66209. private vertexError;
  66210. private calculateError;
  66211. }
  66212. }
  66213. declare module BABYLON {
  66214. interface Scene {
  66215. /** @hidden (Backing field) */
  66216. _simplificationQueue: SimplificationQueue;
  66217. /**
  66218. * Gets or sets the simplification queue attached to the scene
  66219. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66220. */
  66221. simplificationQueue: SimplificationQueue;
  66222. }
  66223. interface Mesh {
  66224. /**
  66225. * Simplify the mesh according to the given array of settings.
  66226. * Function will return immediately and will simplify async
  66227. * @param settings a collection of simplification settings
  66228. * @param parallelProcessing should all levels calculate parallel or one after the other
  66229. * @param simplificationType the type of simplification to run
  66230. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66231. * @returns the current mesh
  66232. */
  66233. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66234. }
  66235. /**
  66236. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66237. * created in a scene
  66238. */
  66239. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66240. /**
  66241. * The component name helpfull to identify the component in the list of scene components.
  66242. */
  66243. readonly name: string;
  66244. /**
  66245. * The scene the component belongs to.
  66246. */
  66247. scene: Scene;
  66248. /**
  66249. * Creates a new instance of the component for the given scene
  66250. * @param scene Defines the scene to register the component in
  66251. */
  66252. constructor(scene: Scene);
  66253. /**
  66254. * Registers the component in a given scene
  66255. */
  66256. register(): void;
  66257. /**
  66258. * Rebuilds the elements related to this component in case of
  66259. * context lost for instance.
  66260. */
  66261. rebuild(): void;
  66262. /**
  66263. * Disposes the component and the associated ressources
  66264. */
  66265. dispose(): void;
  66266. private _beforeCameraUpdate;
  66267. }
  66268. }
  66269. declare module BABYLON {
  66270. interface Mesh {
  66271. /**
  66272. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66273. */
  66274. thinInstanceEnablePicking: boolean;
  66275. /**
  66276. * Creates a new thin instance
  66277. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66278. * @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
  66279. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66280. */
  66281. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66282. /**
  66283. * Adds the transformation (matrix) of the current mesh as a thin instance
  66284. * @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
  66285. * @returns the thin instance index number
  66286. */
  66287. thinInstanceAddSelf(refresh: boolean): number;
  66288. /**
  66289. * Registers a custom attribute to be used with thin instances
  66290. * @param kind name of the attribute
  66291. * @param stride size in floats of the attribute
  66292. */
  66293. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66294. /**
  66295. * Sets the matrix of a thin instance
  66296. * @param index index of the thin instance
  66297. * @param matrix matrix to set
  66298. * @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
  66299. */
  66300. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66301. /**
  66302. * Sets the value of a custom attribute for a thin instance
  66303. * @param kind name of the attribute
  66304. * @param index index of the thin instance
  66305. * @param value value to set
  66306. * @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
  66307. */
  66308. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66309. /**
  66310. * 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.
  66311. */
  66312. thinInstanceCount: number;
  66313. /**
  66314. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66315. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66316. * @param buffer buffer to set
  66317. * @param stride size in floats of each value of the buffer
  66318. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66319. */
  66320. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66321. /**
  66322. * Gets the list of world matrices
  66323. * @return an array containing all the world matrices from the thin instances
  66324. */
  66325. thinInstanceGetWorldMatrices(): Matrix[];
  66326. /**
  66327. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66328. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66329. */
  66330. thinInstanceBufferUpdated(kind: string): void;
  66331. /**
  66332. * Refreshes the bounding info, taking into account all the thin instances defined
  66333. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66334. */
  66335. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66336. /** @hidden */
  66337. _thinInstanceInitializeUserStorage(): void;
  66338. /** @hidden */
  66339. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66340. /** @hidden */
  66341. _userThinInstanceBuffersStorage: {
  66342. data: {
  66343. [key: string]: Float32Array;
  66344. };
  66345. sizes: {
  66346. [key: string]: number;
  66347. };
  66348. vertexBuffers: {
  66349. [key: string]: Nullable<VertexBuffer>;
  66350. };
  66351. strides: {
  66352. [key: string]: number;
  66353. };
  66354. };
  66355. }
  66356. }
  66357. declare module BABYLON {
  66358. /**
  66359. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66360. */
  66361. export interface INavigationEnginePlugin {
  66362. /**
  66363. * plugin name
  66364. */
  66365. name: string;
  66366. /**
  66367. * Creates a navigation mesh
  66368. * @param meshes array of all the geometry used to compute the navigatio mesh
  66369. * @param parameters bunch of parameters used to filter geometry
  66370. */
  66371. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66372. /**
  66373. * Create a navigation mesh debug mesh
  66374. * @param scene is where the mesh will be added
  66375. * @returns debug display mesh
  66376. */
  66377. createDebugNavMesh(scene: Scene): Mesh;
  66378. /**
  66379. * Get a navigation mesh constrained position, closest to the parameter position
  66380. * @param position world position
  66381. * @returns the closest point to position constrained by the navigation mesh
  66382. */
  66383. getClosestPoint(position: Vector3): Vector3;
  66384. /**
  66385. * Get a navigation mesh constrained position, closest to the parameter position
  66386. * @param position world position
  66387. * @param result output the closest point to position constrained by the navigation mesh
  66388. */
  66389. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66390. /**
  66391. * Get a navigation mesh constrained position, within a particular radius
  66392. * @param position world position
  66393. * @param maxRadius the maximum distance to the constrained world position
  66394. * @returns the closest point to position constrained by the navigation mesh
  66395. */
  66396. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66397. /**
  66398. * Get a navigation mesh constrained position, within a particular radius
  66399. * @param position world position
  66400. * @param maxRadius the maximum distance to the constrained world position
  66401. * @param result output the closest point to position constrained by the navigation mesh
  66402. */
  66403. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66404. /**
  66405. * Compute the final position from a segment made of destination-position
  66406. * @param position world position
  66407. * @param destination world position
  66408. * @returns the resulting point along the navmesh
  66409. */
  66410. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66411. /**
  66412. * Compute the final position from a segment made of destination-position
  66413. * @param position world position
  66414. * @param destination world position
  66415. * @param result output the resulting point along the navmesh
  66416. */
  66417. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66418. /**
  66419. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66420. * @param start world position
  66421. * @param end world position
  66422. * @returns array containing world position composing the path
  66423. */
  66424. computePath(start: Vector3, end: Vector3): Vector3[];
  66425. /**
  66426. * If this plugin is supported
  66427. * @returns true if plugin is supported
  66428. */
  66429. isSupported(): boolean;
  66430. /**
  66431. * Create a new Crowd so you can add agents
  66432. * @param maxAgents the maximum agent count in the crowd
  66433. * @param maxAgentRadius the maximum radius an agent can have
  66434. * @param scene to attach the crowd to
  66435. * @returns the crowd you can add agents to
  66436. */
  66437. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66438. /**
  66439. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66440. * The queries will try to find a solution within those bounds
  66441. * default is (1,1,1)
  66442. * @param extent x,y,z value that define the extent around the queries point of reference
  66443. */
  66444. setDefaultQueryExtent(extent: Vector3): void;
  66445. /**
  66446. * Get the Bounding box extent specified by setDefaultQueryExtent
  66447. * @returns the box extent values
  66448. */
  66449. getDefaultQueryExtent(): Vector3;
  66450. /**
  66451. * build the navmesh from a previously saved state using getNavmeshData
  66452. * @param data the Uint8Array returned by getNavmeshData
  66453. */
  66454. buildFromNavmeshData(data: Uint8Array): void;
  66455. /**
  66456. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66457. * @returns data the Uint8Array that can be saved and reused
  66458. */
  66459. getNavmeshData(): Uint8Array;
  66460. /**
  66461. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66462. * @param result output the box extent values
  66463. */
  66464. getDefaultQueryExtentToRef(result: Vector3): void;
  66465. /**
  66466. * Release all resources
  66467. */
  66468. dispose(): void;
  66469. }
  66470. /**
  66471. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66472. */
  66473. export interface ICrowd {
  66474. /**
  66475. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66476. * You can attach anything to that node. The node position is updated in the scene update tick.
  66477. * @param pos world position that will be constrained by the navigation mesh
  66478. * @param parameters agent parameters
  66479. * @param transform hooked to the agent that will be update by the scene
  66480. * @returns agent index
  66481. */
  66482. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66483. /**
  66484. * Returns the agent position in world space
  66485. * @param index agent index returned by addAgent
  66486. * @returns world space position
  66487. */
  66488. getAgentPosition(index: number): Vector3;
  66489. /**
  66490. * Gets the agent position result in world space
  66491. * @param index agent index returned by addAgent
  66492. * @param result output world space position
  66493. */
  66494. getAgentPositionToRef(index: number, result: Vector3): void;
  66495. /**
  66496. * Gets the agent velocity in world space
  66497. * @param index agent index returned by addAgent
  66498. * @returns world space velocity
  66499. */
  66500. getAgentVelocity(index: number): Vector3;
  66501. /**
  66502. * Gets the agent velocity result in world space
  66503. * @param index agent index returned by addAgent
  66504. * @param result output world space velocity
  66505. */
  66506. getAgentVelocityToRef(index: number, result: Vector3): void;
  66507. /**
  66508. * remove a particular agent previously created
  66509. * @param index agent index returned by addAgent
  66510. */
  66511. removeAgent(index: number): void;
  66512. /**
  66513. * get the list of all agents attached to this crowd
  66514. * @returns list of agent indices
  66515. */
  66516. getAgents(): number[];
  66517. /**
  66518. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66519. * @param deltaTime in seconds
  66520. */
  66521. update(deltaTime: number): void;
  66522. /**
  66523. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66524. * @param index agent index returned by addAgent
  66525. * @param destination targeted world position
  66526. */
  66527. agentGoto(index: number, destination: Vector3): void;
  66528. /**
  66529. * Teleport the agent to a new position
  66530. * @param index agent index returned by addAgent
  66531. * @param destination targeted world position
  66532. */
  66533. agentTeleport(index: number, destination: Vector3): void;
  66534. /**
  66535. * Update agent parameters
  66536. * @param index agent index returned by addAgent
  66537. * @param parameters agent parameters
  66538. */
  66539. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66540. /**
  66541. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66542. * The queries will try to find a solution within those bounds
  66543. * default is (1,1,1)
  66544. * @param extent x,y,z value that define the extent around the queries point of reference
  66545. */
  66546. setDefaultQueryExtent(extent: Vector3): void;
  66547. /**
  66548. * Get the Bounding box extent specified by setDefaultQueryExtent
  66549. * @returns the box extent values
  66550. */
  66551. getDefaultQueryExtent(): Vector3;
  66552. /**
  66553. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66554. * @param result output the box extent values
  66555. */
  66556. getDefaultQueryExtentToRef(result: Vector3): void;
  66557. /**
  66558. * Release all resources
  66559. */
  66560. dispose(): void;
  66561. }
  66562. /**
  66563. * Configures an agent
  66564. */
  66565. export interface IAgentParameters {
  66566. /**
  66567. * Agent radius. [Limit: >= 0]
  66568. */
  66569. radius: number;
  66570. /**
  66571. * Agent height. [Limit: > 0]
  66572. */
  66573. height: number;
  66574. /**
  66575. * Maximum allowed acceleration. [Limit: >= 0]
  66576. */
  66577. maxAcceleration: number;
  66578. /**
  66579. * Maximum allowed speed. [Limit: >= 0]
  66580. */
  66581. maxSpeed: number;
  66582. /**
  66583. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66584. */
  66585. collisionQueryRange: number;
  66586. /**
  66587. * The path visibility optimization range. [Limit: > 0]
  66588. */
  66589. pathOptimizationRange: number;
  66590. /**
  66591. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66592. */
  66593. separationWeight: number;
  66594. }
  66595. /**
  66596. * Configures the navigation mesh creation
  66597. */
  66598. export interface INavMeshParameters {
  66599. /**
  66600. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66601. */
  66602. cs: number;
  66603. /**
  66604. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66605. */
  66606. ch: number;
  66607. /**
  66608. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66609. */
  66610. walkableSlopeAngle: number;
  66611. /**
  66612. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66613. * be considered walkable. [Limit: >= 3] [Units: vx]
  66614. */
  66615. walkableHeight: number;
  66616. /**
  66617. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66618. */
  66619. walkableClimb: number;
  66620. /**
  66621. * The distance to erode/shrink the walkable area of the heightfield away from
  66622. * obstructions. [Limit: >=0] [Units: vx]
  66623. */
  66624. walkableRadius: number;
  66625. /**
  66626. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66627. */
  66628. maxEdgeLen: number;
  66629. /**
  66630. * The maximum distance a simplfied contour's border edges should deviate
  66631. * the original raw contour. [Limit: >=0] [Units: vx]
  66632. */
  66633. maxSimplificationError: number;
  66634. /**
  66635. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66636. */
  66637. minRegionArea: number;
  66638. /**
  66639. * Any regions with a span count smaller than this value will, if possible,
  66640. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66641. */
  66642. mergeRegionArea: number;
  66643. /**
  66644. * The maximum number of vertices allowed for polygons generated during the
  66645. * contour to polygon conversion process. [Limit: >= 3]
  66646. */
  66647. maxVertsPerPoly: number;
  66648. /**
  66649. * Sets the sampling distance to use when generating the detail mesh.
  66650. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66651. */
  66652. detailSampleDist: number;
  66653. /**
  66654. * The maximum distance the detail mesh surface should deviate from heightfield
  66655. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66656. */
  66657. detailSampleMaxError: number;
  66658. }
  66659. }
  66660. declare module BABYLON {
  66661. /**
  66662. * RecastJS navigation plugin
  66663. */
  66664. export class RecastJSPlugin implements INavigationEnginePlugin {
  66665. /**
  66666. * Reference to the Recast library
  66667. */
  66668. bjsRECAST: any;
  66669. /**
  66670. * plugin name
  66671. */
  66672. name: string;
  66673. /**
  66674. * the first navmesh created. We might extend this to support multiple navmeshes
  66675. */
  66676. navMesh: any;
  66677. /**
  66678. * Initializes the recastJS plugin
  66679. * @param recastInjection can be used to inject your own recast reference
  66680. */
  66681. constructor(recastInjection?: any);
  66682. /**
  66683. * Creates a navigation mesh
  66684. * @param meshes array of all the geometry used to compute the navigatio mesh
  66685. * @param parameters bunch of parameters used to filter geometry
  66686. */
  66687. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66688. /**
  66689. * Create a navigation mesh debug mesh
  66690. * @param scene is where the mesh will be added
  66691. * @returns debug display mesh
  66692. */
  66693. createDebugNavMesh(scene: Scene): Mesh;
  66694. /**
  66695. * Get a navigation mesh constrained position, closest to the parameter position
  66696. * @param position world position
  66697. * @returns the closest point to position constrained by the navigation mesh
  66698. */
  66699. getClosestPoint(position: Vector3): Vector3;
  66700. /**
  66701. * Get a navigation mesh constrained position, closest to the parameter position
  66702. * @param position world position
  66703. * @param result output the closest point to position constrained by the navigation mesh
  66704. */
  66705. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66706. /**
  66707. * Get a navigation mesh constrained position, within a particular radius
  66708. * @param position world position
  66709. * @param maxRadius the maximum distance to the constrained world position
  66710. * @returns the closest point to position constrained by the navigation mesh
  66711. */
  66712. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66713. /**
  66714. * Get a navigation mesh constrained position, within a particular radius
  66715. * @param position world position
  66716. * @param maxRadius the maximum distance to the constrained world position
  66717. * @param result output the closest point to position constrained by the navigation mesh
  66718. */
  66719. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66720. /**
  66721. * Compute the final position from a segment made of destination-position
  66722. * @param position world position
  66723. * @param destination world position
  66724. * @returns the resulting point along the navmesh
  66725. */
  66726. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66727. /**
  66728. * Compute the final position from a segment made of destination-position
  66729. * @param position world position
  66730. * @param destination world position
  66731. * @param result output the resulting point along the navmesh
  66732. */
  66733. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66734. /**
  66735. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66736. * @param start world position
  66737. * @param end world position
  66738. * @returns array containing world position composing the path
  66739. */
  66740. computePath(start: Vector3, end: Vector3): Vector3[];
  66741. /**
  66742. * Create a new Crowd so you can add agents
  66743. * @param maxAgents the maximum agent count in the crowd
  66744. * @param maxAgentRadius the maximum radius an agent can have
  66745. * @param scene to attach the crowd to
  66746. * @returns the crowd you can add agents to
  66747. */
  66748. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66749. /**
  66750. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66751. * The queries will try to find a solution within those bounds
  66752. * default is (1,1,1)
  66753. * @param extent x,y,z value that define the extent around the queries point of reference
  66754. */
  66755. setDefaultQueryExtent(extent: Vector3): void;
  66756. /**
  66757. * Get the Bounding box extent specified by setDefaultQueryExtent
  66758. * @returns the box extent values
  66759. */
  66760. getDefaultQueryExtent(): Vector3;
  66761. /**
  66762. * build the navmesh from a previously saved state using getNavmeshData
  66763. * @param data the Uint8Array returned by getNavmeshData
  66764. */
  66765. buildFromNavmeshData(data: Uint8Array): void;
  66766. /**
  66767. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66768. * @returns data the Uint8Array that can be saved and reused
  66769. */
  66770. getNavmeshData(): Uint8Array;
  66771. /**
  66772. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66773. * @param result output the box extent values
  66774. */
  66775. getDefaultQueryExtentToRef(result: Vector3): void;
  66776. /**
  66777. * Disposes
  66778. */
  66779. dispose(): void;
  66780. /**
  66781. * If this plugin is supported
  66782. * @returns true if plugin is supported
  66783. */
  66784. isSupported(): boolean;
  66785. }
  66786. /**
  66787. * Recast detour crowd implementation
  66788. */
  66789. export class RecastJSCrowd implements ICrowd {
  66790. /**
  66791. * Recast/detour plugin
  66792. */
  66793. bjsRECASTPlugin: RecastJSPlugin;
  66794. /**
  66795. * Link to the detour crowd
  66796. */
  66797. recastCrowd: any;
  66798. /**
  66799. * One transform per agent
  66800. */
  66801. transforms: TransformNode[];
  66802. /**
  66803. * All agents created
  66804. */
  66805. agents: number[];
  66806. /**
  66807. * Link to the scene is kept to unregister the crowd from the scene
  66808. */
  66809. private _scene;
  66810. /**
  66811. * Observer for crowd updates
  66812. */
  66813. private _onBeforeAnimationsObserver;
  66814. /**
  66815. * Constructor
  66816. * @param plugin recastJS plugin
  66817. * @param maxAgents the maximum agent count in the crowd
  66818. * @param maxAgentRadius the maximum radius an agent can have
  66819. * @param scene to attach the crowd to
  66820. * @returns the crowd you can add agents to
  66821. */
  66822. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66823. /**
  66824. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66825. * You can attach anything to that node. The node position is updated in the scene update tick.
  66826. * @param pos world position that will be constrained by the navigation mesh
  66827. * @param parameters agent parameters
  66828. * @param transform hooked to the agent that will be update by the scene
  66829. * @returns agent index
  66830. */
  66831. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66832. /**
  66833. * Returns the agent position in world space
  66834. * @param index agent index returned by addAgent
  66835. * @returns world space position
  66836. */
  66837. getAgentPosition(index: number): Vector3;
  66838. /**
  66839. * Returns the agent position result in world space
  66840. * @param index agent index returned by addAgent
  66841. * @param result output world space position
  66842. */
  66843. getAgentPositionToRef(index: number, result: Vector3): void;
  66844. /**
  66845. * Returns the agent velocity in world space
  66846. * @param index agent index returned by addAgent
  66847. * @returns world space velocity
  66848. */
  66849. getAgentVelocity(index: number): Vector3;
  66850. /**
  66851. * Returns the agent velocity result in world space
  66852. * @param index agent index returned by addAgent
  66853. * @param result output world space velocity
  66854. */
  66855. getAgentVelocityToRef(index: number, result: Vector3): void;
  66856. /**
  66857. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66858. * @param index agent index returned by addAgent
  66859. * @param destination targeted world position
  66860. */
  66861. agentGoto(index: number, destination: Vector3): void;
  66862. /**
  66863. * Teleport the agent to a new position
  66864. * @param index agent index returned by addAgent
  66865. * @param destination targeted world position
  66866. */
  66867. agentTeleport(index: number, destination: Vector3): void;
  66868. /**
  66869. * Update agent parameters
  66870. * @param index agent index returned by addAgent
  66871. * @param parameters agent parameters
  66872. */
  66873. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66874. /**
  66875. * remove a particular agent previously created
  66876. * @param index agent index returned by addAgent
  66877. */
  66878. removeAgent(index: number): void;
  66879. /**
  66880. * get the list of all agents attached to this crowd
  66881. * @returns list of agent indices
  66882. */
  66883. getAgents(): number[];
  66884. /**
  66885. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66886. * @param deltaTime in seconds
  66887. */
  66888. update(deltaTime: number): void;
  66889. /**
  66890. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66891. * The queries will try to find a solution within those bounds
  66892. * default is (1,1,1)
  66893. * @param extent x,y,z value that define the extent around the queries point of reference
  66894. */
  66895. setDefaultQueryExtent(extent: Vector3): void;
  66896. /**
  66897. * Get the Bounding box extent specified by setDefaultQueryExtent
  66898. * @returns the box extent values
  66899. */
  66900. getDefaultQueryExtent(): Vector3;
  66901. /**
  66902. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66903. * @param result output the box extent values
  66904. */
  66905. getDefaultQueryExtentToRef(result: Vector3): void;
  66906. /**
  66907. * Release all resources
  66908. */
  66909. dispose(): void;
  66910. }
  66911. }
  66912. declare module BABYLON {
  66913. /**
  66914. * Class used to enable access to IndexedDB
  66915. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66916. */
  66917. export class Database implements IOfflineProvider {
  66918. private _callbackManifestChecked;
  66919. private _currentSceneUrl;
  66920. private _db;
  66921. private _enableSceneOffline;
  66922. private _enableTexturesOffline;
  66923. private _manifestVersionFound;
  66924. private _mustUpdateRessources;
  66925. private _hasReachedQuota;
  66926. private _isSupported;
  66927. private _idbFactory;
  66928. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66929. private static IsUASupportingBlobStorage;
  66930. /**
  66931. * Gets a boolean indicating if Database storate is enabled (off by default)
  66932. */
  66933. static IDBStorageEnabled: boolean;
  66934. /**
  66935. * Gets a boolean indicating if scene must be saved in the database
  66936. */
  66937. get enableSceneOffline(): boolean;
  66938. /**
  66939. * Gets a boolean indicating if textures must be saved in the database
  66940. */
  66941. get enableTexturesOffline(): boolean;
  66942. /**
  66943. * Creates a new Database
  66944. * @param urlToScene defines the url to load the scene
  66945. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66946. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66947. */
  66948. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66949. private static _ParseURL;
  66950. private static _ReturnFullUrlLocation;
  66951. private _checkManifestFile;
  66952. /**
  66953. * Open the database and make it available
  66954. * @param successCallback defines the callback to call on success
  66955. * @param errorCallback defines the callback to call on error
  66956. */
  66957. open(successCallback: () => void, errorCallback: () => void): void;
  66958. /**
  66959. * Loads an image from the database
  66960. * @param url defines the url to load from
  66961. * @param image defines the target DOM image
  66962. */
  66963. loadImage(url: string, image: HTMLImageElement): void;
  66964. private _loadImageFromDBAsync;
  66965. private _saveImageIntoDBAsync;
  66966. private _checkVersionFromDB;
  66967. private _loadVersionFromDBAsync;
  66968. private _saveVersionIntoDBAsync;
  66969. /**
  66970. * Loads a file from database
  66971. * @param url defines the URL to load from
  66972. * @param sceneLoaded defines a callback to call on success
  66973. * @param progressCallBack defines a callback to call when progress changed
  66974. * @param errorCallback defines a callback to call on error
  66975. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66976. */
  66977. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66978. private _loadFileAsync;
  66979. private _saveFileAsync;
  66980. /**
  66981. * Validates if xhr data is correct
  66982. * @param xhr defines the request to validate
  66983. * @param dataType defines the expected data type
  66984. * @returns true if data is correct
  66985. */
  66986. private static _ValidateXHRData;
  66987. }
  66988. }
  66989. declare module BABYLON {
  66990. /** @hidden */
  66991. export var gpuUpdateParticlesPixelShader: {
  66992. name: string;
  66993. shader: string;
  66994. };
  66995. }
  66996. declare module BABYLON {
  66997. /** @hidden */
  66998. export var gpuUpdateParticlesVertexShader: {
  66999. name: string;
  67000. shader: string;
  67001. };
  67002. }
  67003. declare module BABYLON {
  67004. /** @hidden */
  67005. export var clipPlaneFragmentDeclaration2: {
  67006. name: string;
  67007. shader: string;
  67008. };
  67009. }
  67010. declare module BABYLON {
  67011. /** @hidden */
  67012. export var gpuRenderParticlesPixelShader: {
  67013. name: string;
  67014. shader: string;
  67015. };
  67016. }
  67017. declare module BABYLON {
  67018. /** @hidden */
  67019. export var clipPlaneVertexDeclaration2: {
  67020. name: string;
  67021. shader: string;
  67022. };
  67023. }
  67024. declare module BABYLON {
  67025. /** @hidden */
  67026. export var gpuRenderParticlesVertexShader: {
  67027. name: string;
  67028. shader: string;
  67029. };
  67030. }
  67031. declare module BABYLON {
  67032. /**
  67033. * This represents a GPU particle system in Babylon
  67034. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67035. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67036. */
  67037. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67038. /**
  67039. * The layer mask we are rendering the particles through.
  67040. */
  67041. layerMask: number;
  67042. private _capacity;
  67043. private _activeCount;
  67044. private _currentActiveCount;
  67045. private _accumulatedCount;
  67046. private _renderEffect;
  67047. private _updateEffect;
  67048. private _buffer0;
  67049. private _buffer1;
  67050. private _spriteBuffer;
  67051. private _updateVAO;
  67052. private _renderVAO;
  67053. private _targetIndex;
  67054. private _sourceBuffer;
  67055. private _targetBuffer;
  67056. private _engine;
  67057. private _currentRenderId;
  67058. private _started;
  67059. private _stopped;
  67060. private _timeDelta;
  67061. private _randomTexture;
  67062. private _randomTexture2;
  67063. private _attributesStrideSize;
  67064. private _updateEffectOptions;
  67065. private _randomTextureSize;
  67066. private _actualFrame;
  67067. private _customEffect;
  67068. private readonly _rawTextureWidth;
  67069. /**
  67070. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67071. */
  67072. static get IsSupported(): boolean;
  67073. /**
  67074. * An event triggered when the system is disposed.
  67075. */
  67076. onDisposeObservable: Observable<IParticleSystem>;
  67077. /**
  67078. * Gets the maximum number of particles active at the same time.
  67079. * @returns The max number of active particles.
  67080. */
  67081. getCapacity(): number;
  67082. /**
  67083. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67084. * to override the particles.
  67085. */
  67086. forceDepthWrite: boolean;
  67087. /**
  67088. * Gets or set the number of active particles
  67089. */
  67090. get activeParticleCount(): number;
  67091. set activeParticleCount(value: number);
  67092. private _preWarmDone;
  67093. /**
  67094. * Specifies if the particles are updated in emitter local space or world space.
  67095. */
  67096. isLocal: boolean;
  67097. /**
  67098. * Is this system ready to be used/rendered
  67099. * @return true if the system is ready
  67100. */
  67101. isReady(): boolean;
  67102. /**
  67103. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67104. * @returns True if it has been started, otherwise false.
  67105. */
  67106. isStarted(): boolean;
  67107. /**
  67108. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67109. * @returns True if it has been stopped, otherwise false.
  67110. */
  67111. isStopped(): boolean;
  67112. /**
  67113. * Gets a boolean indicating that the system is stopping
  67114. * @returns true if the system is currently stopping
  67115. */
  67116. isStopping(): boolean;
  67117. /**
  67118. * Gets the number of particles active at the same time.
  67119. * @returns The number of active particles.
  67120. */
  67121. getActiveCount(): number;
  67122. /**
  67123. * Starts the particle system and begins to emit
  67124. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67125. */
  67126. start(delay?: number): void;
  67127. /**
  67128. * Stops the particle system.
  67129. */
  67130. stop(): void;
  67131. /**
  67132. * Remove all active particles
  67133. */
  67134. reset(): void;
  67135. /**
  67136. * Returns the string "GPUParticleSystem"
  67137. * @returns a string containing the class name
  67138. */
  67139. getClassName(): string;
  67140. /**
  67141. * Gets the custom effect used to render the particles
  67142. * @param blendMode Blend mode for which the effect should be retrieved
  67143. * @returns The effect
  67144. */
  67145. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67146. /**
  67147. * Sets the custom effect used to render the particles
  67148. * @param effect The effect to set
  67149. * @param blendMode Blend mode for which the effect should be set
  67150. */
  67151. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67152. /** @hidden */
  67153. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67154. /**
  67155. * Observable that will be called just before the particles are drawn
  67156. */
  67157. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67158. /**
  67159. * Gets the name of the particle vertex shader
  67160. */
  67161. get vertexShaderName(): string;
  67162. private _colorGradientsTexture;
  67163. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67164. /**
  67165. * Adds a new color gradient
  67166. * @param gradient defines the gradient to use (between 0 and 1)
  67167. * @param color1 defines the color to affect to the specified gradient
  67168. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67169. * @returns the current particle system
  67170. */
  67171. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67172. private _refreshColorGradient;
  67173. /** Force the system to rebuild all gradients that need to be resync */
  67174. forceRefreshGradients(): void;
  67175. /**
  67176. * Remove a specific color gradient
  67177. * @param gradient defines the gradient to remove
  67178. * @returns the current particle system
  67179. */
  67180. removeColorGradient(gradient: number): GPUParticleSystem;
  67181. private _angularSpeedGradientsTexture;
  67182. private _sizeGradientsTexture;
  67183. private _velocityGradientsTexture;
  67184. private _limitVelocityGradientsTexture;
  67185. private _dragGradientsTexture;
  67186. private _addFactorGradient;
  67187. /**
  67188. * Adds a new size gradient
  67189. * @param gradient defines the gradient to use (between 0 and 1)
  67190. * @param factor defines the size factor to affect to the specified gradient
  67191. * @returns the current particle system
  67192. */
  67193. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67194. /**
  67195. * Remove a specific size gradient
  67196. * @param gradient defines the gradient to remove
  67197. * @returns the current particle system
  67198. */
  67199. removeSizeGradient(gradient: number): GPUParticleSystem;
  67200. private _refreshFactorGradient;
  67201. /**
  67202. * Adds a new angular speed gradient
  67203. * @param gradient defines the gradient to use (between 0 and 1)
  67204. * @param factor defines the angular speed to affect to the specified gradient
  67205. * @returns the current particle system
  67206. */
  67207. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67208. /**
  67209. * Remove a specific angular speed gradient
  67210. * @param gradient defines the gradient to remove
  67211. * @returns the current particle system
  67212. */
  67213. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67214. /**
  67215. * Adds a new velocity gradient
  67216. * @param gradient defines the gradient to use (between 0 and 1)
  67217. * @param factor defines the velocity to affect to the specified gradient
  67218. * @returns the current particle system
  67219. */
  67220. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67221. /**
  67222. * Remove a specific velocity gradient
  67223. * @param gradient defines the gradient to remove
  67224. * @returns the current particle system
  67225. */
  67226. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67227. /**
  67228. * Adds a new limit velocity gradient
  67229. * @param gradient defines the gradient to use (between 0 and 1)
  67230. * @param factor defines the limit velocity value to affect to the specified gradient
  67231. * @returns the current particle system
  67232. */
  67233. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67234. /**
  67235. * Remove a specific limit velocity gradient
  67236. * @param gradient defines the gradient to remove
  67237. * @returns the current particle system
  67238. */
  67239. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67240. /**
  67241. * Adds a new drag gradient
  67242. * @param gradient defines the gradient to use (between 0 and 1)
  67243. * @param factor defines the drag value to affect to the specified gradient
  67244. * @returns the current particle system
  67245. */
  67246. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67247. /**
  67248. * Remove a specific drag gradient
  67249. * @param gradient defines the gradient to remove
  67250. * @returns the current particle system
  67251. */
  67252. removeDragGradient(gradient: number): GPUParticleSystem;
  67253. /**
  67254. * Not supported by GPUParticleSystem
  67255. * @param gradient defines the gradient to use (between 0 and 1)
  67256. * @param factor defines the emit rate value to affect to the specified gradient
  67257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67258. * @returns the current particle system
  67259. */
  67260. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67261. /**
  67262. * Not supported by GPUParticleSystem
  67263. * @param gradient defines the gradient to remove
  67264. * @returns the current particle system
  67265. */
  67266. removeEmitRateGradient(gradient: number): IParticleSystem;
  67267. /**
  67268. * Not supported by GPUParticleSystem
  67269. * @param gradient defines the gradient to use (between 0 and 1)
  67270. * @param factor defines the start size value to affect to the specified gradient
  67271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67272. * @returns the current particle system
  67273. */
  67274. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67275. /**
  67276. * Not supported by GPUParticleSystem
  67277. * @param gradient defines the gradient to remove
  67278. * @returns the current particle system
  67279. */
  67280. removeStartSizeGradient(gradient: number): IParticleSystem;
  67281. /**
  67282. * Not supported by GPUParticleSystem
  67283. * @param gradient defines the gradient to use (between 0 and 1)
  67284. * @param min defines the color remap minimal range
  67285. * @param max defines the color remap maximal range
  67286. * @returns the current particle system
  67287. */
  67288. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67289. /**
  67290. * Not supported by GPUParticleSystem
  67291. * @param gradient defines the gradient to remove
  67292. * @returns the current particle system
  67293. */
  67294. removeColorRemapGradient(): IParticleSystem;
  67295. /**
  67296. * Not supported by GPUParticleSystem
  67297. * @param gradient defines the gradient to use (between 0 and 1)
  67298. * @param min defines the alpha remap minimal range
  67299. * @param max defines the alpha remap maximal range
  67300. * @returns the current particle system
  67301. */
  67302. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67303. /**
  67304. * Not supported by GPUParticleSystem
  67305. * @param gradient defines the gradient to remove
  67306. * @returns the current particle system
  67307. */
  67308. removeAlphaRemapGradient(): IParticleSystem;
  67309. /**
  67310. * Not supported by GPUParticleSystem
  67311. * @param gradient defines the gradient to use (between 0 and 1)
  67312. * @param color defines the color to affect to the specified gradient
  67313. * @returns the current particle system
  67314. */
  67315. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67316. /**
  67317. * Not supported by GPUParticleSystem
  67318. * @param gradient defines the gradient to remove
  67319. * @returns the current particle system
  67320. */
  67321. removeRampGradient(): IParticleSystem;
  67322. /**
  67323. * Not supported by GPUParticleSystem
  67324. * @returns the list of ramp gradients
  67325. */
  67326. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67327. /**
  67328. * Not supported by GPUParticleSystem
  67329. * Gets or sets a boolean indicating that ramp gradients must be used
  67330. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67331. */
  67332. get useRampGradients(): boolean;
  67333. set useRampGradients(value: boolean);
  67334. /**
  67335. * Not supported by GPUParticleSystem
  67336. * @param gradient defines the gradient to use (between 0 and 1)
  67337. * @param factor defines the life time factor to affect to the specified gradient
  67338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67339. * @returns the current particle system
  67340. */
  67341. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67342. /**
  67343. * Not supported by GPUParticleSystem
  67344. * @param gradient defines the gradient to remove
  67345. * @returns the current particle system
  67346. */
  67347. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67348. /**
  67349. * Instantiates a GPU particle system.
  67350. * 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.
  67351. * @param name The name of the particle system
  67352. * @param options The options used to create the system
  67353. * @param scene The scene the particle system belongs to
  67354. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67355. * @param customEffect a custom effect used to change the way particles are rendered by default
  67356. */
  67357. constructor(name: string, options: Partial<{
  67358. capacity: number;
  67359. randomTextureSize: number;
  67360. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67361. protected _reset(): void;
  67362. private _createUpdateVAO;
  67363. private _createRenderVAO;
  67364. private _initialize;
  67365. /** @hidden */
  67366. _recreateUpdateEffect(): void;
  67367. private _getEffect;
  67368. /**
  67369. * Fill the defines array according to the current settings of the particle system
  67370. * @param defines Array to be updated
  67371. * @param blendMode blend mode to take into account when updating the array
  67372. */
  67373. fillDefines(defines: Array<string>, blendMode?: number): void;
  67374. /**
  67375. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67376. * @param uniforms Uniforms array to fill
  67377. * @param attributes Attributes array to fill
  67378. * @param samplers Samplers array to fill
  67379. */
  67380. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67381. /** @hidden */
  67382. _recreateRenderEffect(): Effect;
  67383. /**
  67384. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67385. * @param preWarm defines if we are in the pre-warmimg phase
  67386. */
  67387. animate(preWarm?: boolean): void;
  67388. private _createFactorGradientTexture;
  67389. private _createSizeGradientTexture;
  67390. private _createAngularSpeedGradientTexture;
  67391. private _createVelocityGradientTexture;
  67392. private _createLimitVelocityGradientTexture;
  67393. private _createDragGradientTexture;
  67394. private _createColorGradientTexture;
  67395. /**
  67396. * Renders the particle system in its current state
  67397. * @param preWarm defines if the system should only update the particles but not render them
  67398. * @returns the current number of particles
  67399. */
  67400. render(preWarm?: boolean): number;
  67401. /**
  67402. * Rebuilds the particle system
  67403. */
  67404. rebuild(): void;
  67405. private _releaseBuffers;
  67406. private _releaseVAOs;
  67407. /**
  67408. * Disposes the particle system and free the associated resources
  67409. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67410. */
  67411. dispose(disposeTexture?: boolean): void;
  67412. /**
  67413. * Clones the particle system.
  67414. * @param name The name of the cloned object
  67415. * @param newEmitter The new emitter to use
  67416. * @returns the cloned particle system
  67417. */
  67418. clone(name: string, newEmitter: any): GPUParticleSystem;
  67419. /**
  67420. * Serializes the particle system to a JSON object
  67421. * @param serializeTexture defines if the texture must be serialized as well
  67422. * @returns the JSON object
  67423. */
  67424. serialize(serializeTexture?: boolean): any;
  67425. /**
  67426. * Parses a JSON object to create a GPU particle system.
  67427. * @param parsedParticleSystem The JSON object to parse
  67428. * @param scene The scene to create the particle system in
  67429. * @param rootUrl The root url to use to load external dependencies like texture
  67430. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67431. * @returns the parsed GPU particle system
  67432. */
  67433. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67434. }
  67435. }
  67436. declare module BABYLON {
  67437. /**
  67438. * Represents a set of particle systems working together to create a specific effect
  67439. */
  67440. export class ParticleSystemSet implements IDisposable {
  67441. /**
  67442. * Gets or sets base Assets URL
  67443. */
  67444. static BaseAssetsUrl: string;
  67445. private _emitterCreationOptions;
  67446. private _emitterNode;
  67447. /**
  67448. * Gets the particle system list
  67449. */
  67450. systems: IParticleSystem[];
  67451. /**
  67452. * Gets the emitter node used with this set
  67453. */
  67454. get emitterNode(): Nullable<TransformNode>;
  67455. /**
  67456. * Creates a new emitter mesh as a sphere
  67457. * @param options defines the options used to create the sphere
  67458. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67459. * @param scene defines the hosting scene
  67460. */
  67461. setEmitterAsSphere(options: {
  67462. diameter: number;
  67463. segments: number;
  67464. color: Color3;
  67465. }, renderingGroupId: number, scene: Scene): void;
  67466. /**
  67467. * Starts all particle systems of the set
  67468. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67469. */
  67470. start(emitter?: AbstractMesh): void;
  67471. /**
  67472. * Release all associated resources
  67473. */
  67474. dispose(): void;
  67475. /**
  67476. * Serialize the set into a JSON compatible object
  67477. * @param serializeTexture defines if the texture must be serialized as well
  67478. * @returns a JSON compatible representation of the set
  67479. */
  67480. serialize(serializeTexture?: boolean): any;
  67481. /**
  67482. * Parse a new ParticleSystemSet from a serialized source
  67483. * @param data defines a JSON compatible representation of the set
  67484. * @param scene defines the hosting scene
  67485. * @param gpu defines if we want GPU particles or CPU particles
  67486. * @returns a new ParticleSystemSet
  67487. */
  67488. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67489. }
  67490. }
  67491. declare module BABYLON {
  67492. /**
  67493. * This class is made for on one-liner static method to help creating particle system set.
  67494. */
  67495. export class ParticleHelper {
  67496. /**
  67497. * Gets or sets base Assets URL
  67498. */
  67499. static BaseAssetsUrl: string;
  67500. /** Define the Url to load snippets */
  67501. static SnippetUrl: string;
  67502. /**
  67503. * Create a default particle system that you can tweak
  67504. * @param emitter defines the emitter to use
  67505. * @param capacity defines the system capacity (default is 500 particles)
  67506. * @param scene defines the hosting scene
  67507. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67508. * @returns the new Particle system
  67509. */
  67510. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67511. /**
  67512. * This is the main static method (one-liner) of this helper to create different particle systems
  67513. * @param type This string represents the type to the particle system to create
  67514. * @param scene The scene where the particle system should live
  67515. * @param gpu If the system will use gpu
  67516. * @returns the ParticleSystemSet created
  67517. */
  67518. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67519. /**
  67520. * Static function used to export a particle system to a ParticleSystemSet variable.
  67521. * Please note that the emitter shape is not exported
  67522. * @param systems defines the particle systems to export
  67523. * @returns the created particle system set
  67524. */
  67525. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67526. /**
  67527. * Creates a particle system from a snippet saved in a remote file
  67528. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67529. * @param url defines the url to load from
  67530. * @param scene defines the hosting scene
  67531. * @param gpu If the system will use gpu
  67532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67533. * @returns a promise that will resolve to the new particle system
  67534. */
  67535. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67536. /**
  67537. * Creates a particle system from a snippet saved by the particle system editor
  67538. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67539. * @param scene defines the hosting scene
  67540. * @param gpu If the system will use gpu
  67541. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67542. * @returns a promise that will resolve to the new particle system
  67543. */
  67544. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67545. }
  67546. }
  67547. declare module BABYLON {
  67548. interface Engine {
  67549. /**
  67550. * Create an effect to use with particle systems.
  67551. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67552. * the particle system for which you want to create a custom effect in the last parameter
  67553. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67554. * @param uniformsNames defines a list of attribute names
  67555. * @param samplers defines an array of string used to represent textures
  67556. * @param defines defines the string containing the defines to use to compile the shaders
  67557. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67558. * @param onCompiled defines a function to call when the effect creation is successful
  67559. * @param onError defines a function to call when the effect creation has failed
  67560. * @param particleSystem the particle system you want to create the effect for
  67561. * @returns the new Effect
  67562. */
  67563. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67564. }
  67565. interface Mesh {
  67566. /**
  67567. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67568. * @returns an array of IParticleSystem
  67569. */
  67570. getEmittedParticleSystems(): IParticleSystem[];
  67571. /**
  67572. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67573. * @returns an array of IParticleSystem
  67574. */
  67575. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67576. }
  67577. }
  67578. declare module BABYLON {
  67579. /** Defines the 4 color options */
  67580. export enum PointColor {
  67581. /** color value */
  67582. Color = 2,
  67583. /** uv value */
  67584. UV = 1,
  67585. /** random value */
  67586. Random = 0,
  67587. /** stated value */
  67588. Stated = 3
  67589. }
  67590. /**
  67591. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67592. * 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.
  67593. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67594. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67595. *
  67596. * Full documentation here : TO BE ENTERED
  67597. */
  67598. export class PointsCloudSystem implements IDisposable {
  67599. /**
  67600. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67601. * Example : var p = SPS.particles[i];
  67602. */
  67603. particles: CloudPoint[];
  67604. /**
  67605. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67606. */
  67607. nbParticles: number;
  67608. /**
  67609. * This a counter for your own usage. It's not set by any SPS functions.
  67610. */
  67611. counter: number;
  67612. /**
  67613. * The PCS name. This name is also given to the underlying mesh.
  67614. */
  67615. name: string;
  67616. /**
  67617. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67618. */
  67619. mesh: Mesh;
  67620. /**
  67621. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67622. * Please read :
  67623. */
  67624. vars: any;
  67625. /**
  67626. * @hidden
  67627. */
  67628. _size: number;
  67629. private _scene;
  67630. private _promises;
  67631. private _positions;
  67632. private _indices;
  67633. private _normals;
  67634. private _colors;
  67635. private _uvs;
  67636. private _indices32;
  67637. private _positions32;
  67638. private _colors32;
  67639. private _uvs32;
  67640. private _updatable;
  67641. private _isVisibilityBoxLocked;
  67642. private _alwaysVisible;
  67643. private _groups;
  67644. private _groupCounter;
  67645. private _computeParticleColor;
  67646. private _computeParticleTexture;
  67647. private _computeParticleRotation;
  67648. private _computeBoundingBox;
  67649. private _isReady;
  67650. /**
  67651. * Creates a PCS (Points Cloud System) object
  67652. * @param name (String) is the PCS name, this will be the underlying mesh name
  67653. * @param pointSize (number) is the size for each point
  67654. * @param scene (Scene) is the scene in which the PCS is added
  67655. * @param options defines the options of the PCS e.g.
  67656. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67657. */
  67658. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67659. updatable?: boolean;
  67660. });
  67661. /**
  67662. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67663. * If no points were added to the PCS, the returned mesh is just a single point.
  67664. * @returns a promise for the created mesh
  67665. */
  67666. buildMeshAsync(): Promise<Mesh>;
  67667. /**
  67668. * @hidden
  67669. */
  67670. private _buildMesh;
  67671. private _addParticle;
  67672. private _randomUnitVector;
  67673. private _getColorIndicesForCoord;
  67674. private _setPointsColorOrUV;
  67675. private _colorFromTexture;
  67676. private _calculateDensity;
  67677. /**
  67678. * Adds points to the PCS in random positions within a unit sphere
  67679. * @param nb (positive integer) the number of particles to be created from this model
  67680. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67681. * @returns the number of groups in the system
  67682. */
  67683. addPoints(nb: number, pointFunction?: any): number;
  67684. /**
  67685. * Adds points to the PCS from the surface of the model shape
  67686. * @param mesh is any Mesh object that will be used as a surface model for the points
  67687. * @param nb (positive integer) the number of particles to be created from this model
  67688. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67689. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67690. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67691. * @returns the number of groups in the system
  67692. */
  67693. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67694. /**
  67695. * Adds points to the PCS inside the model shape
  67696. * @param mesh is any Mesh object that will be used as a surface model for the points
  67697. * @param nb (positive integer) the number of particles to be created from this model
  67698. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67699. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67700. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67701. * @returns the number of groups in the system
  67702. */
  67703. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67704. /**
  67705. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67706. * This method calls `updateParticle()` for each particle of the SPS.
  67707. * For an animated SPS, it is usually called within the render loop.
  67708. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67709. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67710. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67711. * @returns the PCS.
  67712. */
  67713. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67714. /**
  67715. * Disposes the PCS.
  67716. */
  67717. dispose(): void;
  67718. /**
  67719. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67720. * doc :
  67721. * @returns the PCS.
  67722. */
  67723. refreshVisibleSize(): PointsCloudSystem;
  67724. /**
  67725. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67726. * @param size the size (float) of the visibility box
  67727. * note : this doesn't lock the PCS mesh bounding box.
  67728. * doc :
  67729. */
  67730. setVisibilityBox(size: number): void;
  67731. /**
  67732. * Gets whether the PCS is always visible or not
  67733. * doc :
  67734. */
  67735. get isAlwaysVisible(): boolean;
  67736. /**
  67737. * Sets the PCS as always visible or not
  67738. * doc :
  67739. */
  67740. set isAlwaysVisible(val: boolean);
  67741. /**
  67742. * Tells to `setParticles()` to compute the particle rotations or not
  67743. * Default value : false. The PCS is faster when it's set to false
  67744. * Note : particle rotations are only applied to parent particles
  67745. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67746. */
  67747. set computeParticleRotation(val: boolean);
  67748. /**
  67749. * Tells to `setParticles()` to compute the particle colors or not.
  67750. * Default value : true. The PCS is faster when it's set to false.
  67751. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67752. */
  67753. set computeParticleColor(val: boolean);
  67754. set computeParticleTexture(val: boolean);
  67755. /**
  67756. * Gets if `setParticles()` computes the particle colors or not.
  67757. * Default value : false. The PCS is faster when it's set to false.
  67758. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67759. */
  67760. get computeParticleColor(): boolean;
  67761. /**
  67762. * Gets if `setParticles()` computes the particle textures or not.
  67763. * Default value : false. The PCS is faster when it's set to false.
  67764. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67765. */
  67766. get computeParticleTexture(): boolean;
  67767. /**
  67768. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67769. */
  67770. set computeBoundingBox(val: boolean);
  67771. /**
  67772. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67773. */
  67774. get computeBoundingBox(): boolean;
  67775. /**
  67776. * This function does nothing. It may be overwritten to set all the particle first values.
  67777. * The PCS doesn't call this function, you may have to call it by your own.
  67778. * doc :
  67779. */
  67780. initParticles(): void;
  67781. /**
  67782. * This function does nothing. It may be overwritten to recycle a particle
  67783. * The PCS doesn't call this function, you can to call it
  67784. * doc :
  67785. * @param particle The particle to recycle
  67786. * @returns the recycled particle
  67787. */
  67788. recycleParticle(particle: CloudPoint): CloudPoint;
  67789. /**
  67790. * Updates a particle : this function should be overwritten by the user.
  67791. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67792. * doc :
  67793. * @example : just set a particle position or velocity and recycle conditions
  67794. * @param particle The particle to update
  67795. * @returns the updated particle
  67796. */
  67797. updateParticle(particle: CloudPoint): CloudPoint;
  67798. /**
  67799. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67800. * This does nothing and may be overwritten by the user.
  67801. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67802. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67803. * @param update the boolean update value actually passed to setParticles()
  67804. */
  67805. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67806. /**
  67807. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67808. * This will be passed three parameters.
  67809. * This does nothing and may be overwritten by the user.
  67810. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67811. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67812. * @param update the boolean update value actually passed to setParticles()
  67813. */
  67814. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67815. }
  67816. }
  67817. declare module BABYLON {
  67818. /**
  67819. * Represents one particle of a points cloud system.
  67820. */
  67821. export class CloudPoint {
  67822. /**
  67823. * particle global index
  67824. */
  67825. idx: number;
  67826. /**
  67827. * The color of the particle
  67828. */
  67829. color: Nullable<Color4>;
  67830. /**
  67831. * The world space position of the particle.
  67832. */
  67833. position: Vector3;
  67834. /**
  67835. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67836. */
  67837. rotation: Vector3;
  67838. /**
  67839. * The world space rotation quaternion of the particle.
  67840. */
  67841. rotationQuaternion: Nullable<Quaternion>;
  67842. /**
  67843. * The uv of the particle.
  67844. */
  67845. uv: Nullable<Vector2>;
  67846. /**
  67847. * The current speed of the particle.
  67848. */
  67849. velocity: Vector3;
  67850. /**
  67851. * The pivot point in the particle local space.
  67852. */
  67853. pivot: Vector3;
  67854. /**
  67855. * Must the particle be translated from its pivot point in its local space ?
  67856. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67857. * Default : false
  67858. */
  67859. translateFromPivot: boolean;
  67860. /**
  67861. * Index of this particle in the global "positions" array (Internal use)
  67862. * @hidden
  67863. */
  67864. _pos: number;
  67865. /**
  67866. * @hidden Index of this particle in the global "indices" array (Internal use)
  67867. */
  67868. _ind: number;
  67869. /**
  67870. * Group this particle belongs to
  67871. */
  67872. _group: PointsGroup;
  67873. /**
  67874. * Group id of this particle
  67875. */
  67876. groupId: number;
  67877. /**
  67878. * Index of the particle in its group id (Internal use)
  67879. */
  67880. idxInGroup: number;
  67881. /**
  67882. * @hidden Particle BoundingInfo object (Internal use)
  67883. */
  67884. _boundingInfo: BoundingInfo;
  67885. /**
  67886. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67887. */
  67888. _pcs: PointsCloudSystem;
  67889. /**
  67890. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67891. */
  67892. _stillInvisible: boolean;
  67893. /**
  67894. * @hidden Last computed particle rotation matrix
  67895. */
  67896. _rotationMatrix: number[];
  67897. /**
  67898. * Parent particle Id, if any.
  67899. * Default null.
  67900. */
  67901. parentId: Nullable<number>;
  67902. /**
  67903. * @hidden Internal global position in the PCS.
  67904. */
  67905. _globalPosition: Vector3;
  67906. /**
  67907. * Creates a Point Cloud object.
  67908. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67909. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67910. * @param group (PointsGroup) is the group the particle belongs to
  67911. * @param groupId (integer) is the group identifier in the PCS.
  67912. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67913. * @param pcs defines the PCS it is associated to
  67914. */
  67915. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67916. /**
  67917. * get point size
  67918. */
  67919. get size(): Vector3;
  67920. /**
  67921. * Set point size
  67922. */
  67923. set size(scale: Vector3);
  67924. /**
  67925. * Legacy support, changed quaternion to rotationQuaternion
  67926. */
  67927. get quaternion(): Nullable<Quaternion>;
  67928. /**
  67929. * Legacy support, changed quaternion to rotationQuaternion
  67930. */
  67931. set quaternion(q: Nullable<Quaternion>);
  67932. /**
  67933. * Returns a boolean. True if the particle intersects a mesh, else false
  67934. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67935. * @param target is the object (point or mesh) what the intersection is computed against
  67936. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67937. * @returns true if it intersects
  67938. */
  67939. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67940. /**
  67941. * get the rotation matrix of the particle
  67942. * @hidden
  67943. */
  67944. getRotationMatrix(m: Matrix): void;
  67945. }
  67946. /**
  67947. * Represents a group of points in a points cloud system
  67948. * * PCS internal tool, don't use it manually.
  67949. */
  67950. export class PointsGroup {
  67951. /**
  67952. * The group id
  67953. * @hidden
  67954. */
  67955. groupID: number;
  67956. /**
  67957. * image data for group (internal use)
  67958. * @hidden
  67959. */
  67960. _groupImageData: Nullable<ArrayBufferView>;
  67961. /**
  67962. * Image Width (internal use)
  67963. * @hidden
  67964. */
  67965. _groupImgWidth: number;
  67966. /**
  67967. * Image Height (internal use)
  67968. * @hidden
  67969. */
  67970. _groupImgHeight: number;
  67971. /**
  67972. * Custom position function (internal use)
  67973. * @hidden
  67974. */
  67975. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67976. /**
  67977. * density per facet for surface points
  67978. * @hidden
  67979. */
  67980. _groupDensity: number[];
  67981. /**
  67982. * Only when points are colored by texture carries pointer to texture list array
  67983. * @hidden
  67984. */
  67985. _textureNb: number;
  67986. /**
  67987. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67988. * PCS internal tool, don't use it manually.
  67989. * @hidden
  67990. */
  67991. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. interface Scene {
  67996. /** @hidden (Backing field) */
  67997. _physicsEngine: Nullable<IPhysicsEngine>;
  67998. /** @hidden */
  67999. _physicsTimeAccumulator: number;
  68000. /**
  68001. * Gets the current physics engine
  68002. * @returns a IPhysicsEngine or null if none attached
  68003. */
  68004. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68005. /**
  68006. * Enables physics to the current scene
  68007. * @param gravity defines the scene's gravity for the physics engine
  68008. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68009. * @return a boolean indicating if the physics engine was initialized
  68010. */
  68011. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68012. /**
  68013. * Disables and disposes the physics engine associated with the scene
  68014. */
  68015. disablePhysicsEngine(): void;
  68016. /**
  68017. * Gets a boolean indicating if there is an active physics engine
  68018. * @returns a boolean indicating if there is an active physics engine
  68019. */
  68020. isPhysicsEnabled(): boolean;
  68021. /**
  68022. * Deletes a physics compound impostor
  68023. * @param compound defines the compound to delete
  68024. */
  68025. deleteCompoundImpostor(compound: any): void;
  68026. /**
  68027. * An event triggered when physic simulation is about to be run
  68028. */
  68029. onBeforePhysicsObservable: Observable<Scene>;
  68030. /**
  68031. * An event triggered when physic simulation has been done
  68032. */
  68033. onAfterPhysicsObservable: Observable<Scene>;
  68034. }
  68035. interface AbstractMesh {
  68036. /** @hidden */
  68037. _physicsImpostor: Nullable<PhysicsImpostor>;
  68038. /**
  68039. * Gets or sets impostor used for physic simulation
  68040. * @see https://doc.babylonjs.com/features/physics_engine
  68041. */
  68042. physicsImpostor: Nullable<PhysicsImpostor>;
  68043. /**
  68044. * Gets the current physics impostor
  68045. * @see https://doc.babylonjs.com/features/physics_engine
  68046. * @returns a physics impostor or null
  68047. */
  68048. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68049. /** Apply a physic impulse to the mesh
  68050. * @param force defines the force to apply
  68051. * @param contactPoint defines where to apply the force
  68052. * @returns the current mesh
  68053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68054. */
  68055. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68056. /**
  68057. * Creates a physic joint between two meshes
  68058. * @param otherMesh defines the other mesh to use
  68059. * @param pivot1 defines the pivot to use on this mesh
  68060. * @param pivot2 defines the pivot to use on the other mesh
  68061. * @param options defines additional options (can be plugin dependent)
  68062. * @returns the current mesh
  68063. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68064. */
  68065. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68066. /** @hidden */
  68067. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68068. }
  68069. /**
  68070. * Defines the physics engine scene component responsible to manage a physics engine
  68071. */
  68072. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68073. /**
  68074. * The component name helpful to identify the component in the list of scene components.
  68075. */
  68076. readonly name: string;
  68077. /**
  68078. * The scene the component belongs to.
  68079. */
  68080. scene: Scene;
  68081. /**
  68082. * Creates a new instance of the component for the given scene
  68083. * @param scene Defines the scene to register the component in
  68084. */
  68085. constructor(scene: Scene);
  68086. /**
  68087. * Registers the component in a given scene
  68088. */
  68089. register(): void;
  68090. /**
  68091. * Rebuilds the elements related to this component in case of
  68092. * context lost for instance.
  68093. */
  68094. rebuild(): void;
  68095. /**
  68096. * Disposes the component and the associated ressources
  68097. */
  68098. dispose(): void;
  68099. }
  68100. }
  68101. declare module BABYLON {
  68102. /**
  68103. * A helper for physics simulations
  68104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68105. */
  68106. export class PhysicsHelper {
  68107. private _scene;
  68108. private _physicsEngine;
  68109. /**
  68110. * Initializes the Physics helper
  68111. * @param scene Babylon.js scene
  68112. */
  68113. constructor(scene: Scene);
  68114. /**
  68115. * Applies a radial explosion impulse
  68116. * @param origin the origin of the explosion
  68117. * @param radiusOrEventOptions the radius or the options of radial explosion
  68118. * @param strength the explosion strength
  68119. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68120. * @returns A physics radial explosion event, or null
  68121. */
  68122. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68123. /**
  68124. * Applies a radial explosion force
  68125. * @param origin the origin of the explosion
  68126. * @param radiusOrEventOptions the radius or the options of radial explosion
  68127. * @param strength the explosion strength
  68128. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68129. * @returns A physics radial explosion event, or null
  68130. */
  68131. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68132. /**
  68133. * Creates a gravitational field
  68134. * @param origin the origin of the explosion
  68135. * @param radiusOrEventOptions the radius or the options of radial explosion
  68136. * @param strength the explosion strength
  68137. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68138. * @returns A physics gravitational field event, or null
  68139. */
  68140. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68141. /**
  68142. * Creates a physics updraft event
  68143. * @param origin the origin of the updraft
  68144. * @param radiusOrEventOptions the radius or the options of the updraft
  68145. * @param strength the strength of the updraft
  68146. * @param height the height of the updraft
  68147. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68148. * @returns A physics updraft event, or null
  68149. */
  68150. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68151. /**
  68152. * Creates a physics vortex event
  68153. * @param origin the of the vortex
  68154. * @param radiusOrEventOptions the radius or the options of the vortex
  68155. * @param strength the strength of the vortex
  68156. * @param height the height of the vortex
  68157. * @returns a Physics vortex event, or null
  68158. * A physics vortex event or null
  68159. */
  68160. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68161. }
  68162. /**
  68163. * Represents a physics radial explosion event
  68164. */
  68165. class PhysicsRadialExplosionEvent {
  68166. private _scene;
  68167. private _options;
  68168. private _sphere;
  68169. private _dataFetched;
  68170. /**
  68171. * Initializes a radial explosioin event
  68172. * @param _scene BabylonJS scene
  68173. * @param _options The options for the vortex event
  68174. */
  68175. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68176. /**
  68177. * Returns the data related to the radial explosion event (sphere).
  68178. * @returns The radial explosion event data
  68179. */
  68180. getData(): PhysicsRadialExplosionEventData;
  68181. /**
  68182. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68183. * @param impostor A physics imposter
  68184. * @param origin the origin of the explosion
  68185. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68186. */
  68187. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68188. /**
  68189. * Triggers affecterd impostors callbacks
  68190. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68191. */
  68192. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68193. /**
  68194. * Disposes the sphere.
  68195. * @param force Specifies if the sphere should be disposed by force
  68196. */
  68197. dispose(force?: boolean): void;
  68198. /*** Helpers ***/
  68199. private _prepareSphere;
  68200. private _intersectsWithSphere;
  68201. }
  68202. /**
  68203. * Represents a gravitational field event
  68204. */
  68205. class PhysicsGravitationalFieldEvent {
  68206. private _physicsHelper;
  68207. private _scene;
  68208. private _origin;
  68209. private _options;
  68210. private _tickCallback;
  68211. private _sphere;
  68212. private _dataFetched;
  68213. /**
  68214. * Initializes the physics gravitational field event
  68215. * @param _physicsHelper A physics helper
  68216. * @param _scene BabylonJS scene
  68217. * @param _origin The origin position of the gravitational field event
  68218. * @param _options The options for the vortex event
  68219. */
  68220. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68221. /**
  68222. * Returns the data related to the gravitational field event (sphere).
  68223. * @returns A gravitational field event
  68224. */
  68225. getData(): PhysicsGravitationalFieldEventData;
  68226. /**
  68227. * Enables the gravitational field.
  68228. */
  68229. enable(): void;
  68230. /**
  68231. * Disables the gravitational field.
  68232. */
  68233. disable(): void;
  68234. /**
  68235. * Disposes the sphere.
  68236. * @param force The force to dispose from the gravitational field event
  68237. */
  68238. dispose(force?: boolean): void;
  68239. private _tick;
  68240. }
  68241. /**
  68242. * Represents a physics updraft event
  68243. */
  68244. class PhysicsUpdraftEvent {
  68245. private _scene;
  68246. private _origin;
  68247. private _options;
  68248. private _physicsEngine;
  68249. private _originTop;
  68250. private _originDirection;
  68251. private _tickCallback;
  68252. private _cylinder;
  68253. private _cylinderPosition;
  68254. private _dataFetched;
  68255. /**
  68256. * Initializes the physics updraft event
  68257. * @param _scene BabylonJS scene
  68258. * @param _origin The origin position of the updraft
  68259. * @param _options The options for the updraft event
  68260. */
  68261. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68262. /**
  68263. * Returns the data related to the updraft event (cylinder).
  68264. * @returns A physics updraft event
  68265. */
  68266. getData(): PhysicsUpdraftEventData;
  68267. /**
  68268. * Enables the updraft.
  68269. */
  68270. enable(): void;
  68271. /**
  68272. * Disables the updraft.
  68273. */
  68274. disable(): void;
  68275. /**
  68276. * Disposes the cylinder.
  68277. * @param force Specifies if the updraft should be disposed by force
  68278. */
  68279. dispose(force?: boolean): void;
  68280. private getImpostorHitData;
  68281. private _tick;
  68282. /*** Helpers ***/
  68283. private _prepareCylinder;
  68284. private _intersectsWithCylinder;
  68285. }
  68286. /**
  68287. * Represents a physics vortex event
  68288. */
  68289. class PhysicsVortexEvent {
  68290. private _scene;
  68291. private _origin;
  68292. private _options;
  68293. private _physicsEngine;
  68294. private _originTop;
  68295. private _tickCallback;
  68296. private _cylinder;
  68297. private _cylinderPosition;
  68298. private _dataFetched;
  68299. /**
  68300. * Initializes the physics vortex event
  68301. * @param _scene The BabylonJS scene
  68302. * @param _origin The origin position of the vortex
  68303. * @param _options The options for the vortex event
  68304. */
  68305. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68306. /**
  68307. * Returns the data related to the vortex event (cylinder).
  68308. * @returns The physics vortex event data
  68309. */
  68310. getData(): PhysicsVortexEventData;
  68311. /**
  68312. * Enables the vortex.
  68313. */
  68314. enable(): void;
  68315. /**
  68316. * Disables the cortex.
  68317. */
  68318. disable(): void;
  68319. /**
  68320. * Disposes the sphere.
  68321. * @param force
  68322. */
  68323. dispose(force?: boolean): void;
  68324. private getImpostorHitData;
  68325. private _tick;
  68326. /*** Helpers ***/
  68327. private _prepareCylinder;
  68328. private _intersectsWithCylinder;
  68329. }
  68330. /**
  68331. * Options fot the radial explosion event
  68332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68333. */
  68334. export class PhysicsRadialExplosionEventOptions {
  68335. /**
  68336. * The radius of the sphere for the radial explosion.
  68337. */
  68338. radius: number;
  68339. /**
  68340. * The strenth of the explosion.
  68341. */
  68342. strength: number;
  68343. /**
  68344. * The strenght of the force in correspondence to the distance of the affected object
  68345. */
  68346. falloff: PhysicsRadialImpulseFalloff;
  68347. /**
  68348. * Sphere options for the radial explosion.
  68349. */
  68350. sphere: {
  68351. segments: number;
  68352. diameter: number;
  68353. };
  68354. /**
  68355. * Sphere options for the radial explosion.
  68356. */
  68357. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68358. }
  68359. /**
  68360. * Options fot the updraft event
  68361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68362. */
  68363. export class PhysicsUpdraftEventOptions {
  68364. /**
  68365. * The radius of the cylinder for the vortex
  68366. */
  68367. radius: number;
  68368. /**
  68369. * The strenth of the updraft.
  68370. */
  68371. strength: number;
  68372. /**
  68373. * The height of the cylinder for the updraft.
  68374. */
  68375. height: number;
  68376. /**
  68377. * The mode for the the updraft.
  68378. */
  68379. updraftMode: PhysicsUpdraftMode;
  68380. }
  68381. /**
  68382. * Options fot the vortex event
  68383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68384. */
  68385. export class PhysicsVortexEventOptions {
  68386. /**
  68387. * The radius of the cylinder for the vortex
  68388. */
  68389. radius: number;
  68390. /**
  68391. * The strenth of the vortex.
  68392. */
  68393. strength: number;
  68394. /**
  68395. * The height of the cylinder for the vortex.
  68396. */
  68397. height: number;
  68398. /**
  68399. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68400. */
  68401. centripetalForceThreshold: number;
  68402. /**
  68403. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68404. */
  68405. centripetalForceMultiplier: number;
  68406. /**
  68407. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68408. */
  68409. centrifugalForceMultiplier: number;
  68410. /**
  68411. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68412. */
  68413. updraftForceMultiplier: number;
  68414. }
  68415. /**
  68416. * The strenght of the force in correspondence to the distance of the affected object
  68417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68418. */
  68419. export enum PhysicsRadialImpulseFalloff {
  68420. /** Defines that impulse is constant in strength across it's whole radius */
  68421. Constant = 0,
  68422. /** Defines that impulse gets weaker if it's further from the origin */
  68423. Linear = 1
  68424. }
  68425. /**
  68426. * The strength of the force in correspondence to the distance of the affected object
  68427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68428. */
  68429. export enum PhysicsUpdraftMode {
  68430. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68431. Center = 0,
  68432. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68433. Perpendicular = 1
  68434. }
  68435. /**
  68436. * Interface for a physics hit data
  68437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68438. */
  68439. export interface PhysicsHitData {
  68440. /**
  68441. * The force applied at the contact point
  68442. */
  68443. force: Vector3;
  68444. /**
  68445. * The contact point
  68446. */
  68447. contactPoint: Vector3;
  68448. /**
  68449. * The distance from the origin to the contact point
  68450. */
  68451. distanceFromOrigin: number;
  68452. }
  68453. /**
  68454. * Interface for radial explosion event data
  68455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68456. */
  68457. export interface PhysicsRadialExplosionEventData {
  68458. /**
  68459. * A sphere used for the radial explosion event
  68460. */
  68461. sphere: Mesh;
  68462. }
  68463. /**
  68464. * Interface for gravitational field event data
  68465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68466. */
  68467. export interface PhysicsGravitationalFieldEventData {
  68468. /**
  68469. * A sphere mesh used for the gravitational field event
  68470. */
  68471. sphere: Mesh;
  68472. }
  68473. /**
  68474. * Interface for updraft event data
  68475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68476. */
  68477. export interface PhysicsUpdraftEventData {
  68478. /**
  68479. * A cylinder used for the updraft event
  68480. */
  68481. cylinder: Mesh;
  68482. }
  68483. /**
  68484. * Interface for vortex event data
  68485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68486. */
  68487. export interface PhysicsVortexEventData {
  68488. /**
  68489. * A cylinder used for the vortex event
  68490. */
  68491. cylinder: Mesh;
  68492. }
  68493. /**
  68494. * Interface for an affected physics impostor
  68495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68496. */
  68497. export interface PhysicsAffectedImpostorWithData {
  68498. /**
  68499. * The impostor affected by the effect
  68500. */
  68501. impostor: PhysicsImpostor;
  68502. /**
  68503. * The data about the hit/horce from the explosion
  68504. */
  68505. hitData: PhysicsHitData;
  68506. }
  68507. }
  68508. declare module BABYLON {
  68509. /** @hidden */
  68510. export var blackAndWhitePixelShader: {
  68511. name: string;
  68512. shader: string;
  68513. };
  68514. }
  68515. declare module BABYLON {
  68516. /**
  68517. * Post process used to render in black and white
  68518. */
  68519. export class BlackAndWhitePostProcess extends PostProcess {
  68520. /**
  68521. * Linear about to convert he result to black and white (default: 1)
  68522. */
  68523. degree: number;
  68524. /**
  68525. * Creates a black and white post process
  68526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68527. * @param name The name of the effect.
  68528. * @param options The required width/height ratio to downsize to before computing the render pass.
  68529. * @param camera The camera to apply the render pass to.
  68530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68531. * @param engine The engine which the post process will be applied. (default: current engine)
  68532. * @param reusable If the post process can be reused on the same frame. (default: false)
  68533. */
  68534. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68535. }
  68536. }
  68537. declare module BABYLON {
  68538. /**
  68539. * This represents a set of one or more post processes in Babylon.
  68540. * A post process can be used to apply a shader to a texture after it is rendered.
  68541. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68542. */
  68543. export class PostProcessRenderEffect {
  68544. private _postProcesses;
  68545. private _getPostProcesses;
  68546. private _singleInstance;
  68547. private _cameras;
  68548. private _indicesForCamera;
  68549. /**
  68550. * Name of the effect
  68551. * @hidden
  68552. */
  68553. _name: string;
  68554. /**
  68555. * Instantiates a post process render effect.
  68556. * A post process can be used to apply a shader to a texture after it is rendered.
  68557. * @param engine The engine the effect is tied to
  68558. * @param name The name of the effect
  68559. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68560. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68561. */
  68562. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68563. /**
  68564. * Checks if all the post processes in the effect are supported.
  68565. */
  68566. get isSupported(): boolean;
  68567. /**
  68568. * Updates the current state of the effect
  68569. * @hidden
  68570. */
  68571. _update(): void;
  68572. /**
  68573. * Attaches the effect on cameras
  68574. * @param cameras The camera to attach to.
  68575. * @hidden
  68576. */
  68577. _attachCameras(cameras: Camera): void;
  68578. /**
  68579. * Attaches the effect on cameras
  68580. * @param cameras The camera to attach to.
  68581. * @hidden
  68582. */
  68583. _attachCameras(cameras: Camera[]): void;
  68584. /**
  68585. * Detaches the effect on cameras
  68586. * @param cameras The camera to detatch from.
  68587. * @hidden
  68588. */
  68589. _detachCameras(cameras: Camera): void;
  68590. /**
  68591. * Detatches the effect on cameras
  68592. * @param cameras The camera to detatch from.
  68593. * @hidden
  68594. */
  68595. _detachCameras(cameras: Camera[]): void;
  68596. /**
  68597. * Enables the effect on given cameras
  68598. * @param cameras The camera to enable.
  68599. * @hidden
  68600. */
  68601. _enable(cameras: Camera): void;
  68602. /**
  68603. * Enables the effect on given cameras
  68604. * @param cameras The camera to enable.
  68605. * @hidden
  68606. */
  68607. _enable(cameras: Nullable<Camera[]>): void;
  68608. /**
  68609. * Disables the effect on the given cameras
  68610. * @param cameras The camera to disable.
  68611. * @hidden
  68612. */
  68613. _disable(cameras: Camera): void;
  68614. /**
  68615. * Disables the effect on the given cameras
  68616. * @param cameras The camera to disable.
  68617. * @hidden
  68618. */
  68619. _disable(cameras: Nullable<Camera[]>): void;
  68620. /**
  68621. * Gets a list of the post processes contained in the effect.
  68622. * @param camera The camera to get the post processes on.
  68623. * @returns The list of the post processes in the effect.
  68624. */
  68625. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /** @hidden */
  68630. export var extractHighlightsPixelShader: {
  68631. name: string;
  68632. shader: string;
  68633. };
  68634. }
  68635. declare module BABYLON {
  68636. /**
  68637. * 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.
  68638. */
  68639. export class ExtractHighlightsPostProcess extends PostProcess {
  68640. /**
  68641. * The luminance threshold, pixels below this value will be set to black.
  68642. */
  68643. threshold: number;
  68644. /** @hidden */
  68645. _exposure: number;
  68646. /**
  68647. * Post process which has the input texture to be used when performing highlight extraction
  68648. * @hidden
  68649. */
  68650. _inputPostProcess: Nullable<PostProcess>;
  68651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /** @hidden */
  68656. export var bloomMergePixelShader: {
  68657. name: string;
  68658. shader: string;
  68659. };
  68660. }
  68661. declare module BABYLON {
  68662. /**
  68663. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68664. */
  68665. export class BloomMergePostProcess extends PostProcess {
  68666. /** Weight of the bloom to be added to the original input. */
  68667. weight: number;
  68668. /**
  68669. * Creates a new instance of @see BloomMergePostProcess
  68670. * @param name The name of the effect.
  68671. * @param originalFromInput Post process which's input will be used for the merge.
  68672. * @param blurred Blurred highlights post process which's output will be used.
  68673. * @param weight Weight of the bloom to be added to the original input.
  68674. * @param options The required width/height ratio to downsize to before computing the render pass.
  68675. * @param camera The camera to apply the render pass to.
  68676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68677. * @param engine The engine which the post process will be applied. (default: current engine)
  68678. * @param reusable If the post process can be reused on the same frame. (default: false)
  68679. * @param textureType Type of textures used when performing the post process. (default: 0)
  68680. * @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)
  68681. */
  68682. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68683. /** Weight of the bloom to be added to the original input. */
  68684. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68685. }
  68686. }
  68687. declare module BABYLON {
  68688. /**
  68689. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68690. */
  68691. export class BloomEffect extends PostProcessRenderEffect {
  68692. private bloomScale;
  68693. /**
  68694. * @hidden Internal
  68695. */
  68696. _effects: Array<PostProcess>;
  68697. /**
  68698. * @hidden Internal
  68699. */
  68700. _downscale: ExtractHighlightsPostProcess;
  68701. private _blurX;
  68702. private _blurY;
  68703. private _merge;
  68704. /**
  68705. * The luminance threshold to find bright areas of the image to bloom.
  68706. */
  68707. get threshold(): number;
  68708. set threshold(value: number);
  68709. /**
  68710. * The strength of the bloom.
  68711. */
  68712. get weight(): number;
  68713. set weight(value: number);
  68714. /**
  68715. * Specifies the size of the bloom blur kernel, relative to the final output size
  68716. */
  68717. get kernel(): number;
  68718. set kernel(value: number);
  68719. /**
  68720. * Creates a new instance of @see BloomEffect
  68721. * @param scene The scene the effect belongs to.
  68722. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68723. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68724. * @param bloomWeight The the strength of bloom.
  68725. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68726. * @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)
  68727. */
  68728. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68729. /**
  68730. * Disposes each of the internal effects for a given camera.
  68731. * @param camera The camera to dispose the effect on.
  68732. */
  68733. disposeEffects(camera: Camera): void;
  68734. /**
  68735. * @hidden Internal
  68736. */
  68737. _updateEffects(): void;
  68738. /**
  68739. * Internal
  68740. * @returns if all the contained post processes are ready.
  68741. * @hidden
  68742. */
  68743. _isReady(): boolean;
  68744. }
  68745. }
  68746. declare module BABYLON {
  68747. /** @hidden */
  68748. export var chromaticAberrationPixelShader: {
  68749. name: string;
  68750. shader: string;
  68751. };
  68752. }
  68753. declare module BABYLON {
  68754. /**
  68755. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68756. */
  68757. export class ChromaticAberrationPostProcess extends PostProcess {
  68758. /**
  68759. * The amount of seperation of rgb channels (default: 30)
  68760. */
  68761. aberrationAmount: number;
  68762. /**
  68763. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68764. */
  68765. radialIntensity: number;
  68766. /**
  68767. * 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))
  68768. */
  68769. direction: Vector2;
  68770. /**
  68771. * 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))
  68772. */
  68773. centerPosition: Vector2;
  68774. /**
  68775. * Creates a new instance ChromaticAberrationPostProcess
  68776. * @param name The name of the effect.
  68777. * @param screenWidth The width of the screen to apply the effect on.
  68778. * @param screenHeight The height of the screen to apply the effect on.
  68779. * @param options The required width/height ratio to downsize to before computing the render pass.
  68780. * @param camera The camera to apply the render pass to.
  68781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68782. * @param engine The engine which the post process will be applied. (default: current engine)
  68783. * @param reusable If the post process can be reused on the same frame. (default: false)
  68784. * @param textureType Type of textures used when performing the post process. (default: 0)
  68785. * @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)
  68786. */
  68787. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68788. }
  68789. }
  68790. declare module BABYLON {
  68791. /** @hidden */
  68792. export var circleOfConfusionPixelShader: {
  68793. name: string;
  68794. shader: string;
  68795. };
  68796. }
  68797. declare module BABYLON {
  68798. /**
  68799. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68800. */
  68801. export class CircleOfConfusionPostProcess extends PostProcess {
  68802. /**
  68803. * 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.
  68804. */
  68805. lensSize: number;
  68806. /**
  68807. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68808. */
  68809. fStop: number;
  68810. /**
  68811. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68812. */
  68813. focusDistance: number;
  68814. /**
  68815. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68816. */
  68817. focalLength: number;
  68818. private _depthTexture;
  68819. /**
  68820. * Creates a new instance CircleOfConfusionPostProcess
  68821. * @param name The name of the effect.
  68822. * @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.
  68823. * @param options The required width/height ratio to downsize to before computing the render pass.
  68824. * @param camera The camera to apply the render pass to.
  68825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68826. * @param engine The engine which the post process will be applied. (default: current engine)
  68827. * @param reusable If the post process can be reused on the same frame. (default: false)
  68828. * @param textureType Type of textures used when performing the post process. (default: 0)
  68829. * @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)
  68830. */
  68831. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68832. /**
  68833. * 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.
  68834. */
  68835. set depthTexture(value: RenderTargetTexture);
  68836. }
  68837. }
  68838. declare module BABYLON {
  68839. /** @hidden */
  68840. export var colorCorrectionPixelShader: {
  68841. name: string;
  68842. shader: string;
  68843. };
  68844. }
  68845. declare module BABYLON {
  68846. /**
  68847. *
  68848. * This post-process allows the modification of rendered colors by using
  68849. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68850. *
  68851. * The object needs to be provided an url to a texture containing the color
  68852. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68853. * Use an image editing software to tweak the LUT to match your needs.
  68854. *
  68855. * For an example of a color LUT, see here:
  68856. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68857. * For explanations on color grading, see here:
  68858. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68859. *
  68860. */
  68861. export class ColorCorrectionPostProcess extends PostProcess {
  68862. private _colorTableTexture;
  68863. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68864. }
  68865. }
  68866. declare module BABYLON {
  68867. /** @hidden */
  68868. export var convolutionPixelShader: {
  68869. name: string;
  68870. shader: string;
  68871. };
  68872. }
  68873. declare module BABYLON {
  68874. /**
  68875. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68876. * input texture to perform effects such as edge detection or sharpening
  68877. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68878. */
  68879. export class ConvolutionPostProcess extends PostProcess {
  68880. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68881. kernel: number[];
  68882. /**
  68883. * Creates a new instance ConvolutionPostProcess
  68884. * @param name The name of the effect.
  68885. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68886. * @param options The required width/height ratio to downsize to before computing the render pass.
  68887. * @param camera The camera to apply the render pass to.
  68888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68889. * @param engine The engine which the post process will be applied. (default: current engine)
  68890. * @param reusable If the post process can be reused on the same frame. (default: false)
  68891. * @param textureType Type of textures used when performing the post process. (default: 0)
  68892. */
  68893. constructor(name: string,
  68894. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68895. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68896. /**
  68897. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68898. */
  68899. static EdgeDetect0Kernel: number[];
  68900. /**
  68901. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68902. */
  68903. static EdgeDetect1Kernel: number[];
  68904. /**
  68905. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68906. */
  68907. static EdgeDetect2Kernel: number[];
  68908. /**
  68909. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68910. */
  68911. static SharpenKernel: number[];
  68912. /**
  68913. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68914. */
  68915. static EmbossKernel: number[];
  68916. /**
  68917. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68918. */
  68919. static GaussianKernel: number[];
  68920. }
  68921. }
  68922. declare module BABYLON {
  68923. /**
  68924. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68925. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68926. * based on samples that have a large difference in distance than the center pixel.
  68927. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68928. */
  68929. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68930. direction: Vector2;
  68931. /**
  68932. * Creates a new instance CircleOfConfusionPostProcess
  68933. * @param name The name of the effect.
  68934. * @param scene The scene the effect belongs to.
  68935. * @param direction The direction the blur should be applied.
  68936. * @param kernel The size of the kernel used to blur.
  68937. * @param options The required width/height ratio to downsize to before computing the render pass.
  68938. * @param camera The camera to apply the render pass to.
  68939. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68940. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68942. * @param engine The engine which the post process will be applied. (default: current engine)
  68943. * @param reusable If the post process can be reused on the same frame. (default: false)
  68944. * @param textureType Type of textures used when performing the post process. (default: 0)
  68945. * @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)
  68946. */
  68947. 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);
  68948. }
  68949. }
  68950. declare module BABYLON {
  68951. /** @hidden */
  68952. export var depthOfFieldMergePixelShader: {
  68953. name: string;
  68954. shader: string;
  68955. };
  68956. }
  68957. declare module BABYLON {
  68958. /**
  68959. * Options to be set when merging outputs from the default pipeline.
  68960. */
  68961. export class DepthOfFieldMergePostProcessOptions {
  68962. /**
  68963. * The original image to merge on top of
  68964. */
  68965. originalFromInput: PostProcess;
  68966. /**
  68967. * Parameters to perform the merge of the depth of field effect
  68968. */
  68969. depthOfField?: {
  68970. circleOfConfusion: PostProcess;
  68971. blurSteps: Array<PostProcess>;
  68972. };
  68973. /**
  68974. * Parameters to perform the merge of bloom effect
  68975. */
  68976. bloom?: {
  68977. blurred: PostProcess;
  68978. weight: number;
  68979. };
  68980. }
  68981. /**
  68982. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68983. */
  68984. export class DepthOfFieldMergePostProcess extends PostProcess {
  68985. private blurSteps;
  68986. /**
  68987. * Creates a new instance of DepthOfFieldMergePostProcess
  68988. * @param name The name of the effect.
  68989. * @param originalFromInput Post process which's input will be used for the merge.
  68990. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68991. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68992. * @param options The required width/height ratio to downsize to before computing the render pass.
  68993. * @param camera The camera to apply the render pass to.
  68994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68995. * @param engine The engine which the post process will be applied. (default: current engine)
  68996. * @param reusable If the post process can be reused on the same frame. (default: false)
  68997. * @param textureType Type of textures used when performing the post process. (default: 0)
  68998. * @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)
  68999. */
  69000. 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);
  69001. /**
  69002. * Updates the effect with the current post process compile time values and recompiles the shader.
  69003. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69004. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69005. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69006. * @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
  69007. * @param onCompiled Called when the shader has been compiled.
  69008. * @param onError Called if there is an error when compiling a shader.
  69009. */
  69010. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69011. }
  69012. }
  69013. declare module BABYLON {
  69014. /**
  69015. * Specifies the level of max blur that should be applied when using the depth of field effect
  69016. */
  69017. export enum DepthOfFieldEffectBlurLevel {
  69018. /**
  69019. * Subtle blur
  69020. */
  69021. Low = 0,
  69022. /**
  69023. * Medium blur
  69024. */
  69025. Medium = 1,
  69026. /**
  69027. * Large blur
  69028. */
  69029. High = 2
  69030. }
  69031. /**
  69032. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69033. */
  69034. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69035. private _circleOfConfusion;
  69036. /**
  69037. * @hidden Internal, blurs from high to low
  69038. */
  69039. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69040. private _depthOfFieldBlurY;
  69041. private _dofMerge;
  69042. /**
  69043. * @hidden Internal post processes in depth of field effect
  69044. */
  69045. _effects: Array<PostProcess>;
  69046. /**
  69047. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69048. */
  69049. set focalLength(value: number);
  69050. get focalLength(): number;
  69051. /**
  69052. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69053. */
  69054. set fStop(value: number);
  69055. get fStop(): number;
  69056. /**
  69057. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69058. */
  69059. set focusDistance(value: number);
  69060. get focusDistance(): number;
  69061. /**
  69062. * 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.
  69063. */
  69064. set lensSize(value: number);
  69065. get lensSize(): number;
  69066. /**
  69067. * Creates a new instance DepthOfFieldEffect
  69068. * @param scene The scene the effect belongs to.
  69069. * @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.
  69070. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69071. * @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)
  69072. */
  69073. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69074. /**
  69075. * Get the current class name of the current effet
  69076. * @returns "DepthOfFieldEffect"
  69077. */
  69078. getClassName(): string;
  69079. /**
  69080. * 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.
  69081. */
  69082. set depthTexture(value: RenderTargetTexture);
  69083. /**
  69084. * Disposes each of the internal effects for a given camera.
  69085. * @param camera The camera to dispose the effect on.
  69086. */
  69087. disposeEffects(camera: Camera): void;
  69088. /**
  69089. * @hidden Internal
  69090. */
  69091. _updateEffects(): void;
  69092. /**
  69093. * Internal
  69094. * @returns if all the contained post processes are ready.
  69095. * @hidden
  69096. */
  69097. _isReady(): boolean;
  69098. }
  69099. }
  69100. declare module BABYLON {
  69101. /** @hidden */
  69102. export var displayPassPixelShader: {
  69103. name: string;
  69104. shader: string;
  69105. };
  69106. }
  69107. declare module BABYLON {
  69108. /**
  69109. * DisplayPassPostProcess which produces an output the same as it's input
  69110. */
  69111. export class DisplayPassPostProcess extends PostProcess {
  69112. /**
  69113. * Creates the DisplayPassPostProcess
  69114. * @param name The name of the effect.
  69115. * @param options The required width/height ratio to downsize to before computing the render pass.
  69116. * @param camera The camera to apply the render pass to.
  69117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69118. * @param engine The engine which the post process will be applied. (default: current engine)
  69119. * @param reusable If the post process can be reused on the same frame. (default: false)
  69120. */
  69121. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69122. }
  69123. }
  69124. declare module BABYLON {
  69125. /** @hidden */
  69126. export var filterPixelShader: {
  69127. name: string;
  69128. shader: string;
  69129. };
  69130. }
  69131. declare module BABYLON {
  69132. /**
  69133. * Applies a kernel filter to the image
  69134. */
  69135. export class FilterPostProcess extends PostProcess {
  69136. /** The matrix to be applied to the image */
  69137. kernelMatrix: Matrix;
  69138. /**
  69139. *
  69140. * @param name The name of the effect.
  69141. * @param kernelMatrix The matrix to be applied to the image
  69142. * @param options The required width/height ratio to downsize to before computing the render pass.
  69143. * @param camera The camera to apply the render pass to.
  69144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69145. * @param engine The engine which the post process will be applied. (default: current engine)
  69146. * @param reusable If the post process can be reused on the same frame. (default: false)
  69147. */
  69148. constructor(name: string,
  69149. /** The matrix to be applied to the image */
  69150. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69151. }
  69152. }
  69153. declare module BABYLON {
  69154. /** @hidden */
  69155. export var fxaaPixelShader: {
  69156. name: string;
  69157. shader: string;
  69158. };
  69159. }
  69160. declare module BABYLON {
  69161. /** @hidden */
  69162. export var fxaaVertexShader: {
  69163. name: string;
  69164. shader: string;
  69165. };
  69166. }
  69167. declare module BABYLON {
  69168. /**
  69169. * Fxaa post process
  69170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69171. */
  69172. export class FxaaPostProcess extends PostProcess {
  69173. /** @hidden */
  69174. texelWidth: number;
  69175. /** @hidden */
  69176. texelHeight: number;
  69177. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69178. private _getDefines;
  69179. }
  69180. }
  69181. declare module BABYLON {
  69182. /** @hidden */
  69183. export var grainPixelShader: {
  69184. name: string;
  69185. shader: string;
  69186. };
  69187. }
  69188. declare module BABYLON {
  69189. /**
  69190. * The GrainPostProcess adds noise to the image at mid luminance levels
  69191. */
  69192. export class GrainPostProcess extends PostProcess {
  69193. /**
  69194. * The intensity of the grain added (default: 30)
  69195. */
  69196. intensity: number;
  69197. /**
  69198. * If the grain should be randomized on every frame
  69199. */
  69200. animated: boolean;
  69201. /**
  69202. * Creates a new instance of @see GrainPostProcess
  69203. * @param name The name of the effect.
  69204. * @param options The required width/height ratio to downsize to before computing the render pass.
  69205. * @param camera The camera to apply the render pass to.
  69206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69207. * @param engine The engine which the post process will be applied. (default: current engine)
  69208. * @param reusable If the post process can be reused on the same frame. (default: false)
  69209. * @param textureType Type of textures used when performing the post process. (default: 0)
  69210. * @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)
  69211. */
  69212. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69213. }
  69214. }
  69215. declare module BABYLON {
  69216. /** @hidden */
  69217. export var highlightsPixelShader: {
  69218. name: string;
  69219. shader: string;
  69220. };
  69221. }
  69222. declare module BABYLON {
  69223. /**
  69224. * Extracts highlights from the image
  69225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69226. */
  69227. export class HighlightsPostProcess extends PostProcess {
  69228. /**
  69229. * Extracts highlights from the image
  69230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69231. * @param name The name of the effect.
  69232. * @param options The required width/height ratio to downsize to before computing the render pass.
  69233. * @param camera The camera to apply the render pass to.
  69234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69235. * @param engine The engine which the post process will be applied. (default: current engine)
  69236. * @param reusable If the post process can be reused on the same frame. (default: false)
  69237. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69238. */
  69239. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69240. }
  69241. }
  69242. declare module BABYLON {
  69243. /** @hidden */
  69244. export var mrtFragmentDeclaration: {
  69245. name: string;
  69246. shader: string;
  69247. };
  69248. }
  69249. declare module BABYLON {
  69250. /** @hidden */
  69251. export var geometryPixelShader: {
  69252. name: string;
  69253. shader: string;
  69254. };
  69255. }
  69256. declare module BABYLON {
  69257. /** @hidden */
  69258. export var geometryVertexShader: {
  69259. name: string;
  69260. shader: string;
  69261. };
  69262. }
  69263. declare module BABYLON {
  69264. /** @hidden */
  69265. interface ISavedTransformationMatrix {
  69266. world: Matrix;
  69267. viewProjection: Matrix;
  69268. }
  69269. /**
  69270. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69271. */
  69272. export class GeometryBufferRenderer {
  69273. /**
  69274. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69275. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69276. */
  69277. static readonly POSITION_TEXTURE_TYPE: number;
  69278. /**
  69279. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69280. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69281. */
  69282. static readonly VELOCITY_TEXTURE_TYPE: number;
  69283. /**
  69284. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69285. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69286. */
  69287. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69288. /**
  69289. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69290. * in order to compute objects velocities when enableVelocity is set to "true"
  69291. * @hidden
  69292. */
  69293. _previousTransformationMatrices: {
  69294. [index: number]: ISavedTransformationMatrix;
  69295. };
  69296. /**
  69297. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69298. * in order to compute objects velocities when enableVelocity is set to "true"
  69299. * @hidden
  69300. */
  69301. _previousBonesTransformationMatrices: {
  69302. [index: number]: Float32Array;
  69303. };
  69304. /**
  69305. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69306. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69307. */
  69308. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69309. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69310. renderTransparentMeshes: boolean;
  69311. private _scene;
  69312. private _resizeObserver;
  69313. private _multiRenderTarget;
  69314. private _ratio;
  69315. private _enablePosition;
  69316. private _enableVelocity;
  69317. private _enableReflectivity;
  69318. private _positionIndex;
  69319. private _velocityIndex;
  69320. private _reflectivityIndex;
  69321. protected _effect: Effect;
  69322. protected _cachedDefines: string;
  69323. /**
  69324. * Set the render list (meshes to be rendered) used in the G buffer.
  69325. */
  69326. set renderList(meshes: Mesh[]);
  69327. /**
  69328. * Gets wether or not G buffer are supported by the running hardware.
  69329. * This requires draw buffer supports
  69330. */
  69331. get isSupported(): boolean;
  69332. /**
  69333. * Returns the index of the given texture type in the G-Buffer textures array
  69334. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69335. * @returns the index of the given texture type in the G-Buffer textures array
  69336. */
  69337. getTextureIndex(textureType: number): number;
  69338. /**
  69339. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69340. */
  69341. get enablePosition(): boolean;
  69342. /**
  69343. * Sets whether or not objects positions are enabled for the G buffer.
  69344. */
  69345. set enablePosition(enable: boolean);
  69346. /**
  69347. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69348. */
  69349. get enableVelocity(): boolean;
  69350. /**
  69351. * Sets wether or not objects velocities are enabled for the G buffer.
  69352. */
  69353. set enableVelocity(enable: boolean);
  69354. /**
  69355. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69356. */
  69357. get enableReflectivity(): boolean;
  69358. /**
  69359. * Sets wether or not objects roughness are enabled for the G buffer.
  69360. */
  69361. set enableReflectivity(enable: boolean);
  69362. /**
  69363. * Gets the scene associated with the buffer.
  69364. */
  69365. get scene(): Scene;
  69366. /**
  69367. * Gets the ratio used by the buffer during its creation.
  69368. * How big is the buffer related to the main canvas.
  69369. */
  69370. get ratio(): number;
  69371. /** @hidden */
  69372. static _SceneComponentInitialization: (scene: Scene) => void;
  69373. /**
  69374. * Creates a new G Buffer for the scene
  69375. * @param scene The scene the buffer belongs to
  69376. * @param ratio How big is the buffer related to the main canvas.
  69377. */
  69378. constructor(scene: Scene, ratio?: number);
  69379. /**
  69380. * Checks wether everything is ready to render a submesh to the G buffer.
  69381. * @param subMesh the submesh to check readiness for
  69382. * @param useInstances is the mesh drawn using instance or not
  69383. * @returns true if ready otherwise false
  69384. */
  69385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69386. /**
  69387. * Gets the current underlying G Buffer.
  69388. * @returns the buffer
  69389. */
  69390. getGBuffer(): MultiRenderTarget;
  69391. /**
  69392. * Gets the number of samples used to render the buffer (anti aliasing).
  69393. */
  69394. get samples(): number;
  69395. /**
  69396. * Sets the number of samples used to render the buffer (anti aliasing).
  69397. */
  69398. set samples(value: number);
  69399. /**
  69400. * Disposes the renderer and frees up associated resources.
  69401. */
  69402. dispose(): void;
  69403. protected _createRenderTargets(): void;
  69404. private _copyBonesTransformationMatrices;
  69405. }
  69406. }
  69407. declare module BABYLON {
  69408. interface Scene {
  69409. /** @hidden (Backing field) */
  69410. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69411. /**
  69412. * Gets or Sets the current geometry buffer associated to the scene.
  69413. */
  69414. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69415. /**
  69416. * Enables a GeometryBufferRender and associates it with the scene
  69417. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69418. * @returns the GeometryBufferRenderer
  69419. */
  69420. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69421. /**
  69422. * Disables the GeometryBufferRender associated with the scene
  69423. */
  69424. disableGeometryBufferRenderer(): void;
  69425. }
  69426. /**
  69427. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69428. * in several rendering techniques.
  69429. */
  69430. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69431. /**
  69432. * The component name helpful to identify the component in the list of scene components.
  69433. */
  69434. readonly name: string;
  69435. /**
  69436. * The scene the component belongs to.
  69437. */
  69438. scene: Scene;
  69439. /**
  69440. * Creates a new instance of the component for the given scene
  69441. * @param scene Defines the scene to register the component in
  69442. */
  69443. constructor(scene: Scene);
  69444. /**
  69445. * Registers the component in a given scene
  69446. */
  69447. register(): void;
  69448. /**
  69449. * Rebuilds the elements related to this component in case of
  69450. * context lost for instance.
  69451. */
  69452. rebuild(): void;
  69453. /**
  69454. * Disposes the component and the associated ressources
  69455. */
  69456. dispose(): void;
  69457. private _gatherRenderTargets;
  69458. }
  69459. }
  69460. declare module BABYLON {
  69461. /** @hidden */
  69462. export var motionBlurPixelShader: {
  69463. name: string;
  69464. shader: string;
  69465. };
  69466. }
  69467. declare module BABYLON {
  69468. /**
  69469. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69470. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69471. * As an example, all you have to do is to create the post-process:
  69472. * var mb = new BABYLON.MotionBlurPostProcess(
  69473. * 'mb', // The name of the effect.
  69474. * scene, // The scene containing the objects to blur according to their velocity.
  69475. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69476. * camera // The camera to apply the render pass to.
  69477. * );
  69478. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69479. */
  69480. export class MotionBlurPostProcess extends PostProcess {
  69481. /**
  69482. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69483. */
  69484. motionStrength: number;
  69485. /**
  69486. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69487. */
  69488. get motionBlurSamples(): number;
  69489. /**
  69490. * Sets the number of iterations to be used for motion blur quality
  69491. */
  69492. set motionBlurSamples(samples: number);
  69493. private _motionBlurSamples;
  69494. private _geometryBufferRenderer;
  69495. /**
  69496. * Creates a new instance MotionBlurPostProcess
  69497. * @param name The name of the effect.
  69498. * @param scene The scene containing the objects to blur according to their velocity.
  69499. * @param options The required width/height ratio to downsize to before computing the render pass.
  69500. * @param camera The camera to apply the render pass to.
  69501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69502. * @param engine The engine which the post process will be applied. (default: current engine)
  69503. * @param reusable If the post process can be reused on the same frame. (default: false)
  69504. * @param textureType Type of textures used when performing the post process. (default: 0)
  69505. * @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)
  69506. */
  69507. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69508. /**
  69509. * Excludes the given skinned mesh from computing bones velocities.
  69510. * 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.
  69511. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69512. */
  69513. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69514. /**
  69515. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69516. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69517. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69518. */
  69519. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69520. /**
  69521. * Disposes the post process.
  69522. * @param camera The camera to dispose the post process on.
  69523. */
  69524. dispose(camera?: Camera): void;
  69525. }
  69526. }
  69527. declare module BABYLON {
  69528. /** @hidden */
  69529. export var refractionPixelShader: {
  69530. name: string;
  69531. shader: string;
  69532. };
  69533. }
  69534. declare module BABYLON {
  69535. /**
  69536. * Post process which applies a refractin texture
  69537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69538. */
  69539. export class RefractionPostProcess extends PostProcess {
  69540. /** the base color of the refraction (used to taint the rendering) */
  69541. color: Color3;
  69542. /** simulated refraction depth */
  69543. depth: number;
  69544. /** the coefficient of the base color (0 to remove base color tainting) */
  69545. colorLevel: number;
  69546. private _refTexture;
  69547. private _ownRefractionTexture;
  69548. /**
  69549. * Gets or sets the refraction texture
  69550. * Please note that you are responsible for disposing the texture if you set it manually
  69551. */
  69552. get refractionTexture(): Texture;
  69553. set refractionTexture(value: Texture);
  69554. /**
  69555. * Initializes the RefractionPostProcess
  69556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69557. * @param name The name of the effect.
  69558. * @param refractionTextureUrl Url of the refraction texture to use
  69559. * @param color the base color of the refraction (used to taint the rendering)
  69560. * @param depth simulated refraction depth
  69561. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69562. * @param camera The camera to apply the render pass to.
  69563. * @param options The required width/height ratio to downsize to before computing the render pass.
  69564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69565. * @param engine The engine which the post process will be applied. (default: current engine)
  69566. * @param reusable If the post process can be reused on the same frame. (default: false)
  69567. */
  69568. constructor(name: string, refractionTextureUrl: string,
  69569. /** the base color of the refraction (used to taint the rendering) */
  69570. color: Color3,
  69571. /** simulated refraction depth */
  69572. depth: number,
  69573. /** the coefficient of the base color (0 to remove base color tainting) */
  69574. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69575. /**
  69576. * Disposes of the post process
  69577. * @param camera Camera to dispose post process on
  69578. */
  69579. dispose(camera: Camera): void;
  69580. }
  69581. }
  69582. declare module BABYLON {
  69583. /** @hidden */
  69584. export var sharpenPixelShader: {
  69585. name: string;
  69586. shader: string;
  69587. };
  69588. }
  69589. declare module BABYLON {
  69590. /**
  69591. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69592. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69593. */
  69594. export class SharpenPostProcess extends PostProcess {
  69595. /**
  69596. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69597. */
  69598. colorAmount: number;
  69599. /**
  69600. * How much sharpness should be applied (default: 0.3)
  69601. */
  69602. edgeAmount: number;
  69603. /**
  69604. * Creates a new instance ConvolutionPostProcess
  69605. * @param name The name of the effect.
  69606. * @param options The required width/height ratio to downsize to before computing the render pass.
  69607. * @param camera The camera to apply the render pass to.
  69608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69609. * @param engine The engine which the post process will be applied. (default: current engine)
  69610. * @param reusable If the post process can be reused on the same frame. (default: false)
  69611. * @param textureType Type of textures used when performing the post process. (default: 0)
  69612. * @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)
  69613. */
  69614. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69615. }
  69616. }
  69617. declare module BABYLON {
  69618. /**
  69619. * PostProcessRenderPipeline
  69620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69621. */
  69622. export class PostProcessRenderPipeline {
  69623. private engine;
  69624. private _renderEffects;
  69625. private _renderEffectsForIsolatedPass;
  69626. /**
  69627. * List of inspectable custom properties (used by the Inspector)
  69628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69629. */
  69630. inspectableCustomProperties: IInspectable[];
  69631. /**
  69632. * @hidden
  69633. */
  69634. protected _cameras: Camera[];
  69635. /** @hidden */
  69636. _name: string;
  69637. /**
  69638. * Gets pipeline name
  69639. */
  69640. get name(): string;
  69641. /** Gets the list of attached cameras */
  69642. get cameras(): Camera[];
  69643. /**
  69644. * Initializes a PostProcessRenderPipeline
  69645. * @param engine engine to add the pipeline to
  69646. * @param name name of the pipeline
  69647. */
  69648. constructor(engine: Engine, name: string);
  69649. /**
  69650. * Gets the class name
  69651. * @returns "PostProcessRenderPipeline"
  69652. */
  69653. getClassName(): string;
  69654. /**
  69655. * If all the render effects in the pipeline are supported
  69656. */
  69657. get isSupported(): boolean;
  69658. /**
  69659. * Adds an effect to the pipeline
  69660. * @param renderEffect the effect to add
  69661. */
  69662. addEffect(renderEffect: PostProcessRenderEffect): void;
  69663. /** @hidden */
  69664. _rebuild(): void;
  69665. /** @hidden */
  69666. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69667. /** @hidden */
  69668. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69669. /** @hidden */
  69670. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69671. /** @hidden */
  69672. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69673. /** @hidden */
  69674. _attachCameras(cameras: Camera, unique: boolean): void;
  69675. /** @hidden */
  69676. _attachCameras(cameras: Camera[], unique: boolean): void;
  69677. /** @hidden */
  69678. _detachCameras(cameras: Camera): void;
  69679. /** @hidden */
  69680. _detachCameras(cameras: Nullable<Camera[]>): void;
  69681. /** @hidden */
  69682. _update(): void;
  69683. /** @hidden */
  69684. _reset(): void;
  69685. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69686. /**
  69687. * Sets the required values to the prepass renderer.
  69688. * @param prePassRenderer defines the prepass renderer to setup.
  69689. * @returns true if the pre pass is needed.
  69690. */
  69691. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69692. /**
  69693. * Disposes of the pipeline
  69694. */
  69695. dispose(): void;
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * PostProcessRenderPipelineManager class
  69701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69702. */
  69703. export class PostProcessRenderPipelineManager {
  69704. private _renderPipelines;
  69705. /**
  69706. * Initializes a PostProcessRenderPipelineManager
  69707. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69708. */
  69709. constructor();
  69710. /**
  69711. * Gets the list of supported render pipelines
  69712. */
  69713. get supportedPipelines(): PostProcessRenderPipeline[];
  69714. /**
  69715. * Adds a pipeline to the manager
  69716. * @param renderPipeline The pipeline to add
  69717. */
  69718. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69719. /**
  69720. * Attaches a camera to the pipeline
  69721. * @param renderPipelineName The name of the pipeline to attach to
  69722. * @param cameras the camera to attach
  69723. * @param unique if the camera can be attached multiple times to the pipeline
  69724. */
  69725. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69726. /**
  69727. * Detaches a camera from the pipeline
  69728. * @param renderPipelineName The name of the pipeline to detach from
  69729. * @param cameras the camera to detach
  69730. */
  69731. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69732. /**
  69733. * Enables an effect by name on a pipeline
  69734. * @param renderPipelineName the name of the pipeline to enable the effect in
  69735. * @param renderEffectName the name of the effect to enable
  69736. * @param cameras the cameras that the effect should be enabled on
  69737. */
  69738. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69739. /**
  69740. * Disables an effect by name on a pipeline
  69741. * @param renderPipelineName the name of the pipeline to disable the effect in
  69742. * @param renderEffectName the name of the effect to disable
  69743. * @param cameras the cameras that the effect should be disabled on
  69744. */
  69745. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69746. /**
  69747. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69748. */
  69749. update(): void;
  69750. /** @hidden */
  69751. _rebuild(): void;
  69752. /**
  69753. * Disposes of the manager and pipelines
  69754. */
  69755. dispose(): void;
  69756. }
  69757. }
  69758. declare module BABYLON {
  69759. interface Scene {
  69760. /** @hidden (Backing field) */
  69761. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69762. /**
  69763. * Gets the postprocess render pipeline manager
  69764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69765. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69766. */
  69767. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69768. }
  69769. /**
  69770. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69771. */
  69772. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69773. /**
  69774. * The component name helpfull to identify the component in the list of scene components.
  69775. */
  69776. readonly name: string;
  69777. /**
  69778. * The scene the component belongs to.
  69779. */
  69780. scene: Scene;
  69781. /**
  69782. * Creates a new instance of the component for the given scene
  69783. * @param scene Defines the scene to register the component in
  69784. */
  69785. constructor(scene: Scene);
  69786. /**
  69787. * Registers the component in a given scene
  69788. */
  69789. register(): void;
  69790. /**
  69791. * Rebuilds the elements related to this component in case of
  69792. * context lost for instance.
  69793. */
  69794. rebuild(): void;
  69795. /**
  69796. * Disposes the component and the associated ressources
  69797. */
  69798. dispose(): void;
  69799. private _gatherRenderTargets;
  69800. }
  69801. }
  69802. declare module BABYLON {
  69803. /**
  69804. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69805. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69806. */
  69807. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69808. private _scene;
  69809. private _camerasToBeAttached;
  69810. /**
  69811. * ID of the sharpen post process,
  69812. */
  69813. private readonly SharpenPostProcessId;
  69814. /**
  69815. * @ignore
  69816. * ID of the image processing post process;
  69817. */
  69818. readonly ImageProcessingPostProcessId: string;
  69819. /**
  69820. * @ignore
  69821. * ID of the Fast Approximate Anti-Aliasing post process;
  69822. */
  69823. readonly FxaaPostProcessId: string;
  69824. /**
  69825. * ID of the chromatic aberration post process,
  69826. */
  69827. private readonly ChromaticAberrationPostProcessId;
  69828. /**
  69829. * ID of the grain post process
  69830. */
  69831. private readonly GrainPostProcessId;
  69832. /**
  69833. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69834. */
  69835. sharpen: SharpenPostProcess;
  69836. private _sharpenEffect;
  69837. private bloom;
  69838. /**
  69839. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69840. */
  69841. depthOfField: DepthOfFieldEffect;
  69842. /**
  69843. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69844. */
  69845. fxaa: FxaaPostProcess;
  69846. /**
  69847. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69848. */
  69849. imageProcessing: ImageProcessingPostProcess;
  69850. /**
  69851. * Chromatic aberration post process which will shift rgb colors in the image
  69852. */
  69853. chromaticAberration: ChromaticAberrationPostProcess;
  69854. private _chromaticAberrationEffect;
  69855. /**
  69856. * Grain post process which add noise to the image
  69857. */
  69858. grain: GrainPostProcess;
  69859. private _grainEffect;
  69860. /**
  69861. * Glow post process which adds a glow to emissive areas of the image
  69862. */
  69863. private _glowLayer;
  69864. /**
  69865. * Animations which can be used to tweak settings over a period of time
  69866. */
  69867. animations: Animation[];
  69868. private _imageProcessingConfigurationObserver;
  69869. private _sharpenEnabled;
  69870. private _bloomEnabled;
  69871. private _depthOfFieldEnabled;
  69872. private _depthOfFieldBlurLevel;
  69873. private _fxaaEnabled;
  69874. private _imageProcessingEnabled;
  69875. private _defaultPipelineTextureType;
  69876. private _bloomScale;
  69877. private _chromaticAberrationEnabled;
  69878. private _grainEnabled;
  69879. private _buildAllowed;
  69880. /**
  69881. * Gets active scene
  69882. */
  69883. get scene(): Scene;
  69884. /**
  69885. * Enable or disable the sharpen process from the pipeline
  69886. */
  69887. set sharpenEnabled(enabled: boolean);
  69888. get sharpenEnabled(): boolean;
  69889. private _resizeObserver;
  69890. private _hardwareScaleLevel;
  69891. private _bloomKernel;
  69892. /**
  69893. * Specifies the size of the bloom blur kernel, relative to the final output size
  69894. */
  69895. get bloomKernel(): number;
  69896. set bloomKernel(value: number);
  69897. /**
  69898. * Specifies the weight of the bloom in the final rendering
  69899. */
  69900. private _bloomWeight;
  69901. /**
  69902. * Specifies the luma threshold for the area that will be blurred by the bloom
  69903. */
  69904. private _bloomThreshold;
  69905. private _hdr;
  69906. /**
  69907. * The strength of the bloom.
  69908. */
  69909. set bloomWeight(value: number);
  69910. get bloomWeight(): number;
  69911. /**
  69912. * The strength of the bloom.
  69913. */
  69914. set bloomThreshold(value: number);
  69915. get bloomThreshold(): number;
  69916. /**
  69917. * The scale of the bloom, lower value will provide better performance.
  69918. */
  69919. set bloomScale(value: number);
  69920. get bloomScale(): number;
  69921. /**
  69922. * Enable or disable the bloom from the pipeline
  69923. */
  69924. set bloomEnabled(enabled: boolean);
  69925. get bloomEnabled(): boolean;
  69926. private _rebuildBloom;
  69927. /**
  69928. * If the depth of field is enabled.
  69929. */
  69930. get depthOfFieldEnabled(): boolean;
  69931. set depthOfFieldEnabled(enabled: boolean);
  69932. /**
  69933. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69934. */
  69935. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69936. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69937. /**
  69938. * If the anti aliasing is enabled.
  69939. */
  69940. set fxaaEnabled(enabled: boolean);
  69941. get fxaaEnabled(): boolean;
  69942. private _samples;
  69943. /**
  69944. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69945. */
  69946. set samples(sampleCount: number);
  69947. get samples(): number;
  69948. /**
  69949. * If image processing is enabled.
  69950. */
  69951. set imageProcessingEnabled(enabled: boolean);
  69952. get imageProcessingEnabled(): boolean;
  69953. /**
  69954. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69955. */
  69956. set glowLayerEnabled(enabled: boolean);
  69957. get glowLayerEnabled(): boolean;
  69958. /**
  69959. * Gets the glow layer (or null if not defined)
  69960. */
  69961. get glowLayer(): Nullable<GlowLayer>;
  69962. /**
  69963. * Enable or disable the chromaticAberration process from the pipeline
  69964. */
  69965. set chromaticAberrationEnabled(enabled: boolean);
  69966. get chromaticAberrationEnabled(): boolean;
  69967. /**
  69968. * Enable or disable the grain process from the pipeline
  69969. */
  69970. set grainEnabled(enabled: boolean);
  69971. get grainEnabled(): boolean;
  69972. /**
  69973. * @constructor
  69974. * @param name - The rendering pipeline name (default: "")
  69975. * @param hdr - If high dynamic range textures should be used (default: true)
  69976. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69977. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69978. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69979. */
  69980. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69981. /**
  69982. * Get the class name
  69983. * @returns "DefaultRenderingPipeline"
  69984. */
  69985. getClassName(): string;
  69986. /**
  69987. * Force the compilation of the entire pipeline.
  69988. */
  69989. prepare(): void;
  69990. private _hasCleared;
  69991. private _prevPostProcess;
  69992. private _prevPrevPostProcess;
  69993. private _setAutoClearAndTextureSharing;
  69994. private _depthOfFieldSceneObserver;
  69995. private _buildPipeline;
  69996. private _disposePostProcesses;
  69997. /**
  69998. * Adds a camera to the pipeline
  69999. * @param camera the camera to be added
  70000. */
  70001. addCamera(camera: Camera): void;
  70002. /**
  70003. * Removes a camera from the pipeline
  70004. * @param camera the camera to remove
  70005. */
  70006. removeCamera(camera: Camera): void;
  70007. /**
  70008. * Dispose of the pipeline and stop all post processes
  70009. */
  70010. dispose(): void;
  70011. /**
  70012. * Serialize the rendering pipeline (Used when exporting)
  70013. * @returns the serialized object
  70014. */
  70015. serialize(): any;
  70016. /**
  70017. * Parse the serialized pipeline
  70018. * @param source Source pipeline.
  70019. * @param scene The scene to load the pipeline to.
  70020. * @param rootUrl The URL of the serialized pipeline.
  70021. * @returns An instantiated pipeline from the serialized object.
  70022. */
  70023. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /** @hidden */
  70028. export var lensHighlightsPixelShader: {
  70029. name: string;
  70030. shader: string;
  70031. };
  70032. }
  70033. declare module BABYLON {
  70034. /** @hidden */
  70035. export var depthOfFieldPixelShader: {
  70036. name: string;
  70037. shader: string;
  70038. };
  70039. }
  70040. declare module BABYLON {
  70041. /**
  70042. * BABYLON.JS Chromatic Aberration GLSL Shader
  70043. * Author: Olivier Guyot
  70044. * Separates very slightly R, G and B colors on the edges of the screen
  70045. * Inspired by Francois Tarlier & Martins Upitis
  70046. */
  70047. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70048. /**
  70049. * @ignore
  70050. * The chromatic aberration PostProcess id in the pipeline
  70051. */
  70052. LensChromaticAberrationEffect: string;
  70053. /**
  70054. * @ignore
  70055. * The highlights enhancing PostProcess id in the pipeline
  70056. */
  70057. HighlightsEnhancingEffect: string;
  70058. /**
  70059. * @ignore
  70060. * The depth-of-field PostProcess id in the pipeline
  70061. */
  70062. LensDepthOfFieldEffect: string;
  70063. private _scene;
  70064. private _depthTexture;
  70065. private _grainTexture;
  70066. private _chromaticAberrationPostProcess;
  70067. private _highlightsPostProcess;
  70068. private _depthOfFieldPostProcess;
  70069. private _edgeBlur;
  70070. private _grainAmount;
  70071. private _chromaticAberration;
  70072. private _distortion;
  70073. private _highlightsGain;
  70074. private _highlightsThreshold;
  70075. private _dofDistance;
  70076. private _dofAperture;
  70077. private _dofDarken;
  70078. private _dofPentagon;
  70079. private _blurNoise;
  70080. /**
  70081. * @constructor
  70082. *
  70083. * Effect parameters are as follow:
  70084. * {
  70085. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70086. * edge_blur: number; // from 0 to x (1 for realism)
  70087. * distortion: number; // from 0 to x (1 for realism)
  70088. * grain_amount: number; // from 0 to 1
  70089. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70090. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70091. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70092. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70093. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70094. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70095. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70096. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70097. * }
  70098. * Note: if an effect parameter is unset, effect is disabled
  70099. *
  70100. * @param name The rendering pipeline name
  70101. * @param parameters - An object containing all parameters (see above)
  70102. * @param scene The scene linked to this pipeline
  70103. * @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)
  70104. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70105. */
  70106. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70107. /**
  70108. * Get the class name
  70109. * @returns "LensRenderingPipeline"
  70110. */
  70111. getClassName(): string;
  70112. /**
  70113. * Gets associated scene
  70114. */
  70115. get scene(): Scene;
  70116. /**
  70117. * Gets or sets the edge blur
  70118. */
  70119. get edgeBlur(): number;
  70120. set edgeBlur(value: number);
  70121. /**
  70122. * Gets or sets the grain amount
  70123. */
  70124. get grainAmount(): number;
  70125. set grainAmount(value: number);
  70126. /**
  70127. * Gets or sets the chromatic aberration amount
  70128. */
  70129. get chromaticAberration(): number;
  70130. set chromaticAberration(value: number);
  70131. /**
  70132. * Gets or sets the depth of field aperture
  70133. */
  70134. get dofAperture(): number;
  70135. set dofAperture(value: number);
  70136. /**
  70137. * Gets or sets the edge distortion
  70138. */
  70139. get edgeDistortion(): number;
  70140. set edgeDistortion(value: number);
  70141. /**
  70142. * Gets or sets the depth of field distortion
  70143. */
  70144. get dofDistortion(): number;
  70145. set dofDistortion(value: number);
  70146. /**
  70147. * Gets or sets the darken out of focus amount
  70148. */
  70149. get darkenOutOfFocus(): number;
  70150. set darkenOutOfFocus(value: number);
  70151. /**
  70152. * Gets or sets a boolean indicating if blur noise is enabled
  70153. */
  70154. get blurNoise(): boolean;
  70155. set blurNoise(value: boolean);
  70156. /**
  70157. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70158. */
  70159. get pentagonBokeh(): boolean;
  70160. set pentagonBokeh(value: boolean);
  70161. /**
  70162. * Gets or sets the highlight grain amount
  70163. */
  70164. get highlightsGain(): number;
  70165. set highlightsGain(value: number);
  70166. /**
  70167. * Gets or sets the highlight threshold
  70168. */
  70169. get highlightsThreshold(): number;
  70170. set highlightsThreshold(value: number);
  70171. /**
  70172. * Sets the amount of blur at the edges
  70173. * @param amount blur amount
  70174. */
  70175. setEdgeBlur(amount: number): void;
  70176. /**
  70177. * Sets edge blur to 0
  70178. */
  70179. disableEdgeBlur(): void;
  70180. /**
  70181. * Sets the amout of grain
  70182. * @param amount Amount of grain
  70183. */
  70184. setGrainAmount(amount: number): void;
  70185. /**
  70186. * Set grain amount to 0
  70187. */
  70188. disableGrain(): void;
  70189. /**
  70190. * Sets the chromatic aberration amount
  70191. * @param amount amount of chromatic aberration
  70192. */
  70193. setChromaticAberration(amount: number): void;
  70194. /**
  70195. * Sets chromatic aberration amount to 0
  70196. */
  70197. disableChromaticAberration(): void;
  70198. /**
  70199. * Sets the EdgeDistortion amount
  70200. * @param amount amount of EdgeDistortion
  70201. */
  70202. setEdgeDistortion(amount: number): void;
  70203. /**
  70204. * Sets edge distortion to 0
  70205. */
  70206. disableEdgeDistortion(): void;
  70207. /**
  70208. * Sets the FocusDistance amount
  70209. * @param amount amount of FocusDistance
  70210. */
  70211. setFocusDistance(amount: number): void;
  70212. /**
  70213. * Disables depth of field
  70214. */
  70215. disableDepthOfField(): void;
  70216. /**
  70217. * Sets the Aperture amount
  70218. * @param amount amount of Aperture
  70219. */
  70220. setAperture(amount: number): void;
  70221. /**
  70222. * Sets the DarkenOutOfFocus amount
  70223. * @param amount amount of DarkenOutOfFocus
  70224. */
  70225. setDarkenOutOfFocus(amount: number): void;
  70226. private _pentagonBokehIsEnabled;
  70227. /**
  70228. * Creates a pentagon bokeh effect
  70229. */
  70230. enablePentagonBokeh(): void;
  70231. /**
  70232. * Disables the pentagon bokeh effect
  70233. */
  70234. disablePentagonBokeh(): void;
  70235. /**
  70236. * Enables noise blur
  70237. */
  70238. enableNoiseBlur(): void;
  70239. /**
  70240. * Disables noise blur
  70241. */
  70242. disableNoiseBlur(): void;
  70243. /**
  70244. * Sets the HighlightsGain amount
  70245. * @param amount amount of HighlightsGain
  70246. */
  70247. setHighlightsGain(amount: number): void;
  70248. /**
  70249. * Sets the HighlightsThreshold amount
  70250. * @param amount amount of HighlightsThreshold
  70251. */
  70252. setHighlightsThreshold(amount: number): void;
  70253. /**
  70254. * Disables highlights
  70255. */
  70256. disableHighlights(): void;
  70257. /**
  70258. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70259. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70260. */
  70261. dispose(disableDepthRender?: boolean): void;
  70262. private _createChromaticAberrationPostProcess;
  70263. private _createHighlightsPostProcess;
  70264. private _createDepthOfFieldPostProcess;
  70265. private _createGrainTexture;
  70266. }
  70267. }
  70268. declare module BABYLON {
  70269. /** @hidden */
  70270. export var ssao2PixelShader: {
  70271. name: string;
  70272. shader: string;
  70273. };
  70274. }
  70275. declare module BABYLON {
  70276. /** @hidden */
  70277. export var ssaoCombinePixelShader: {
  70278. name: string;
  70279. shader: string;
  70280. };
  70281. }
  70282. declare module BABYLON {
  70283. /**
  70284. * Render pipeline to produce ssao effect
  70285. */
  70286. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70287. /**
  70288. * @ignore
  70289. * The PassPostProcess id in the pipeline that contains the original scene color
  70290. */
  70291. SSAOOriginalSceneColorEffect: string;
  70292. /**
  70293. * @ignore
  70294. * The SSAO PostProcess id in the pipeline
  70295. */
  70296. SSAORenderEffect: string;
  70297. /**
  70298. * @ignore
  70299. * The horizontal blur PostProcess id in the pipeline
  70300. */
  70301. SSAOBlurHRenderEffect: string;
  70302. /**
  70303. * @ignore
  70304. * The vertical blur PostProcess id in the pipeline
  70305. */
  70306. SSAOBlurVRenderEffect: string;
  70307. /**
  70308. * @ignore
  70309. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70310. */
  70311. SSAOCombineRenderEffect: string;
  70312. /**
  70313. * The output strength of the SSAO post-process. Default value is 1.0.
  70314. */
  70315. totalStrength: number;
  70316. /**
  70317. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70318. */
  70319. maxZ: number;
  70320. /**
  70321. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70322. */
  70323. minZAspect: number;
  70324. private _samples;
  70325. /**
  70326. * Number of samples used for the SSAO calculations. Default value is 8
  70327. */
  70328. set samples(n: number);
  70329. get samples(): number;
  70330. private _textureSamples;
  70331. /**
  70332. * Number of samples to use for antialiasing
  70333. */
  70334. set textureSamples(n: number);
  70335. get textureSamples(): number;
  70336. /**
  70337. * Force rendering the geometry through geometry buffer
  70338. */
  70339. private _forceGeometryBuffer;
  70340. /**
  70341. * Ratio object used for SSAO ratio and blur ratio
  70342. */
  70343. private _ratio;
  70344. /**
  70345. * Dynamically generated sphere sampler.
  70346. */
  70347. private _sampleSphere;
  70348. /**
  70349. * Blur filter offsets
  70350. */
  70351. private _samplerOffsets;
  70352. private _expensiveBlur;
  70353. /**
  70354. * If bilateral blur should be used
  70355. */
  70356. set expensiveBlur(b: boolean);
  70357. get expensiveBlur(): boolean;
  70358. /**
  70359. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70360. */
  70361. radius: number;
  70362. /**
  70363. * The base color of the SSAO post-process
  70364. * The final result is "base + ssao" between [0, 1]
  70365. */
  70366. base: number;
  70367. /**
  70368. * Support test.
  70369. */
  70370. static get IsSupported(): boolean;
  70371. private _scene;
  70372. private _randomTexture;
  70373. private _originalColorPostProcess;
  70374. private _ssaoPostProcess;
  70375. private _blurHPostProcess;
  70376. private _blurVPostProcess;
  70377. private _ssaoCombinePostProcess;
  70378. private _prePassRenderer;
  70379. /**
  70380. * Gets active scene
  70381. */
  70382. get scene(): Scene;
  70383. /**
  70384. * @constructor
  70385. * @param name The rendering pipeline name
  70386. * @param scene The scene linked to this pipeline
  70387. * @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 }
  70388. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70389. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70390. */
  70391. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70392. /**
  70393. * Get the class name
  70394. * @returns "SSAO2RenderingPipeline"
  70395. */
  70396. getClassName(): string;
  70397. /**
  70398. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70399. */
  70400. dispose(disableGeometryBufferRenderer?: boolean): void;
  70401. private _createBlurPostProcess;
  70402. /** @hidden */
  70403. _rebuild(): void;
  70404. private _bits;
  70405. private _radicalInverse_VdC;
  70406. private _hammersley;
  70407. private _hemisphereSample_uniform;
  70408. private _generateHemisphere;
  70409. private _getDefinesForSSAO;
  70410. private _createSSAOPostProcess;
  70411. private _createSSAOCombinePostProcess;
  70412. private _createRandomTexture;
  70413. /**
  70414. * Serialize the rendering pipeline (Used when exporting)
  70415. * @returns the serialized object
  70416. */
  70417. serialize(): any;
  70418. /**
  70419. * Parse the serialized pipeline
  70420. * @param source Source pipeline.
  70421. * @param scene The scene to load the pipeline to.
  70422. * @param rootUrl The URL of the serialized pipeline.
  70423. * @returns An instantiated pipeline from the serialized object.
  70424. */
  70425. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70426. /**
  70427. * Sets the required values to the prepass renderer.
  70428. * @param prePassRenderer defines the prepass renderer to setup
  70429. * @returns true if the pre pass is needed.
  70430. */
  70431. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70432. }
  70433. }
  70434. declare module BABYLON {
  70435. /** @hidden */
  70436. export var ssaoPixelShader: {
  70437. name: string;
  70438. shader: string;
  70439. };
  70440. }
  70441. declare module BABYLON {
  70442. /**
  70443. * Render pipeline to produce ssao effect
  70444. */
  70445. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70446. /**
  70447. * @ignore
  70448. * The PassPostProcess id in the pipeline that contains the original scene color
  70449. */
  70450. SSAOOriginalSceneColorEffect: string;
  70451. /**
  70452. * @ignore
  70453. * The SSAO PostProcess id in the pipeline
  70454. */
  70455. SSAORenderEffect: string;
  70456. /**
  70457. * @ignore
  70458. * The horizontal blur PostProcess id in the pipeline
  70459. */
  70460. SSAOBlurHRenderEffect: string;
  70461. /**
  70462. * @ignore
  70463. * The vertical blur PostProcess id in the pipeline
  70464. */
  70465. SSAOBlurVRenderEffect: string;
  70466. /**
  70467. * @ignore
  70468. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70469. */
  70470. SSAOCombineRenderEffect: string;
  70471. /**
  70472. * The output strength of the SSAO post-process. Default value is 1.0.
  70473. */
  70474. totalStrength: number;
  70475. /**
  70476. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70477. */
  70478. radius: number;
  70479. /**
  70480. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70481. * Must not be equal to fallOff and superior to fallOff.
  70482. * Default value is 0.0075
  70483. */
  70484. area: number;
  70485. /**
  70486. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70487. * Must not be equal to area and inferior to area.
  70488. * Default value is 0.000001
  70489. */
  70490. fallOff: number;
  70491. /**
  70492. * The base color of the SSAO post-process
  70493. * The final result is "base + ssao" between [0, 1]
  70494. */
  70495. base: number;
  70496. private _scene;
  70497. private _depthTexture;
  70498. private _randomTexture;
  70499. private _originalColorPostProcess;
  70500. private _ssaoPostProcess;
  70501. private _blurHPostProcess;
  70502. private _blurVPostProcess;
  70503. private _ssaoCombinePostProcess;
  70504. private _firstUpdate;
  70505. /**
  70506. * Gets active scene
  70507. */
  70508. get scene(): Scene;
  70509. /**
  70510. * @constructor
  70511. * @param name - The rendering pipeline name
  70512. * @param scene - The scene linked to this pipeline
  70513. * @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 }
  70514. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70515. */
  70516. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70517. /**
  70518. * Get the class name
  70519. * @returns "SSAORenderingPipeline"
  70520. */
  70521. getClassName(): string;
  70522. /**
  70523. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70524. */
  70525. dispose(disableDepthRender?: boolean): void;
  70526. private _createBlurPostProcess;
  70527. /** @hidden */
  70528. _rebuild(): void;
  70529. private _createSSAOPostProcess;
  70530. private _createSSAOCombinePostProcess;
  70531. private _createRandomTexture;
  70532. }
  70533. }
  70534. declare module BABYLON {
  70535. /** @hidden */
  70536. export var screenSpaceReflectionPixelShader: {
  70537. name: string;
  70538. shader: string;
  70539. };
  70540. }
  70541. declare module BABYLON {
  70542. /**
  70543. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70544. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70545. */
  70546. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70547. /**
  70548. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70549. */
  70550. threshold: number;
  70551. /**
  70552. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70553. */
  70554. strength: number;
  70555. /**
  70556. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70557. */
  70558. reflectionSpecularFalloffExponent: number;
  70559. /**
  70560. * 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]
  70561. */
  70562. step: number;
  70563. /**
  70564. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70565. */
  70566. roughnessFactor: number;
  70567. private _geometryBufferRenderer;
  70568. private _enableSmoothReflections;
  70569. private _reflectionSamples;
  70570. private _smoothSteps;
  70571. /**
  70572. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70573. * @param name The name of the effect.
  70574. * @param scene The scene containing the objects to calculate reflections.
  70575. * @param options The required width/height ratio to downsize to before computing the render pass.
  70576. * @param camera The camera to apply the render pass to.
  70577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70578. * @param engine The engine which the post process will be applied. (default: current engine)
  70579. * @param reusable If the post process can be reused on the same frame. (default: false)
  70580. * @param textureType Type of textures used when performing the post process. (default: 0)
  70581. * @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)
  70582. */
  70583. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70584. /**
  70585. * Gets wether or not smoothing reflections is enabled.
  70586. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70587. */
  70588. get enableSmoothReflections(): boolean;
  70589. /**
  70590. * Sets wether or not smoothing reflections is enabled.
  70591. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70592. */
  70593. set enableSmoothReflections(enabled: boolean);
  70594. /**
  70595. * Gets the number of samples taken while computing reflections. More samples count is high,
  70596. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70597. */
  70598. get reflectionSamples(): number;
  70599. /**
  70600. * Sets the number of samples taken while computing reflections. More samples count is high,
  70601. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70602. */
  70603. set reflectionSamples(samples: number);
  70604. /**
  70605. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70606. * more the post-process will require GPU power and can generate a drop in FPS.
  70607. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70608. */
  70609. get smoothSteps(): number;
  70610. set smoothSteps(steps: number);
  70611. private _updateEffectDefines;
  70612. }
  70613. }
  70614. declare module BABYLON {
  70615. /** @hidden */
  70616. export var standardPixelShader: {
  70617. name: string;
  70618. shader: string;
  70619. };
  70620. }
  70621. declare module BABYLON {
  70622. /**
  70623. * Standard rendering pipeline
  70624. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70625. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70626. */
  70627. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70628. /**
  70629. * Public members
  70630. */
  70631. /**
  70632. * Post-process which contains the original scene color before the pipeline applies all the effects
  70633. */
  70634. originalPostProcess: Nullable<PostProcess>;
  70635. /**
  70636. * Post-process used to down scale an image x4
  70637. */
  70638. downSampleX4PostProcess: Nullable<PostProcess>;
  70639. /**
  70640. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70641. */
  70642. brightPassPostProcess: Nullable<PostProcess>;
  70643. /**
  70644. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70645. */
  70646. blurHPostProcesses: PostProcess[];
  70647. /**
  70648. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70649. */
  70650. blurVPostProcesses: PostProcess[];
  70651. /**
  70652. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70653. */
  70654. textureAdderPostProcess: Nullable<PostProcess>;
  70655. /**
  70656. * Post-process used to create volumetric lighting effect
  70657. */
  70658. volumetricLightPostProcess: Nullable<PostProcess>;
  70659. /**
  70660. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70661. */
  70662. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70663. /**
  70664. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70665. */
  70666. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70667. /**
  70668. * Post-process used to merge the volumetric light effect and the real scene color
  70669. */
  70670. volumetricLightMergePostProces: Nullable<PostProcess>;
  70671. /**
  70672. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70673. */
  70674. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70675. /**
  70676. * Base post-process used to calculate the average luminance of the final image for HDR
  70677. */
  70678. luminancePostProcess: Nullable<PostProcess>;
  70679. /**
  70680. * Post-processes used to create down sample post-processes in order to get
  70681. * the average luminance of the final image for HDR
  70682. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70683. */
  70684. luminanceDownSamplePostProcesses: PostProcess[];
  70685. /**
  70686. * Post-process used to create a HDR effect (light adaptation)
  70687. */
  70688. hdrPostProcess: Nullable<PostProcess>;
  70689. /**
  70690. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70691. */
  70692. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70693. /**
  70694. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70695. */
  70696. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70697. /**
  70698. * Post-process used to merge the final HDR post-process and the real scene color
  70699. */
  70700. hdrFinalPostProcess: Nullable<PostProcess>;
  70701. /**
  70702. * Post-process used to create a lens flare effect
  70703. */
  70704. lensFlarePostProcess: Nullable<PostProcess>;
  70705. /**
  70706. * Post-process that merges the result of the lens flare post-process and the real scene color
  70707. */
  70708. lensFlareComposePostProcess: Nullable<PostProcess>;
  70709. /**
  70710. * Post-process used to create a motion blur effect
  70711. */
  70712. motionBlurPostProcess: Nullable<PostProcess>;
  70713. /**
  70714. * Post-process used to create a depth of field effect
  70715. */
  70716. depthOfFieldPostProcess: Nullable<PostProcess>;
  70717. /**
  70718. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70719. */
  70720. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70721. /**
  70722. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70723. */
  70724. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70725. /**
  70726. * Represents the brightness threshold in order to configure the illuminated surfaces
  70727. */
  70728. brightThreshold: number;
  70729. /**
  70730. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70731. */
  70732. blurWidth: number;
  70733. /**
  70734. * Sets if the blur for highlighted surfaces must be only horizontal
  70735. */
  70736. horizontalBlur: boolean;
  70737. /**
  70738. * Gets the overall exposure used by the pipeline
  70739. */
  70740. get exposure(): number;
  70741. /**
  70742. * Sets the overall exposure used by the pipeline
  70743. */
  70744. set exposure(value: number);
  70745. /**
  70746. * Texture used typically to simulate "dirty" on camera lens
  70747. */
  70748. lensTexture: Nullable<Texture>;
  70749. /**
  70750. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70751. */
  70752. volumetricLightCoefficient: number;
  70753. /**
  70754. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70755. */
  70756. volumetricLightPower: number;
  70757. /**
  70758. * Used the set the blur intensity to smooth the volumetric lights
  70759. */
  70760. volumetricLightBlurScale: number;
  70761. /**
  70762. * Light (spot or directional) used to generate the volumetric lights rays
  70763. * The source light must have a shadow generate so the pipeline can get its
  70764. * depth map
  70765. */
  70766. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70767. /**
  70768. * For eye adaptation, represents the minimum luminance the eye can see
  70769. */
  70770. hdrMinimumLuminance: number;
  70771. /**
  70772. * For eye adaptation, represents the decrease luminance speed
  70773. */
  70774. hdrDecreaseRate: number;
  70775. /**
  70776. * For eye adaptation, represents the increase luminance speed
  70777. */
  70778. hdrIncreaseRate: number;
  70779. /**
  70780. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70781. */
  70782. get hdrAutoExposure(): boolean;
  70783. /**
  70784. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70785. */
  70786. set hdrAutoExposure(value: boolean);
  70787. /**
  70788. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70789. */
  70790. lensColorTexture: Nullable<Texture>;
  70791. /**
  70792. * The overall strengh for the lens flare effect
  70793. */
  70794. lensFlareStrength: number;
  70795. /**
  70796. * Dispersion coefficient for lens flare ghosts
  70797. */
  70798. lensFlareGhostDispersal: number;
  70799. /**
  70800. * Main lens flare halo width
  70801. */
  70802. lensFlareHaloWidth: number;
  70803. /**
  70804. * Based on the lens distortion effect, defines how much the lens flare result
  70805. * is distorted
  70806. */
  70807. lensFlareDistortionStrength: number;
  70808. /**
  70809. * Configures the blur intensity used for for lens flare (halo)
  70810. */
  70811. lensFlareBlurWidth: number;
  70812. /**
  70813. * Lens star texture must be used to simulate rays on the flares and is available
  70814. * in the documentation
  70815. */
  70816. lensStarTexture: Nullable<Texture>;
  70817. /**
  70818. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70819. * flare effect by taking account of the dirt texture
  70820. */
  70821. lensFlareDirtTexture: Nullable<Texture>;
  70822. /**
  70823. * Represents the focal length for the depth of field effect
  70824. */
  70825. depthOfFieldDistance: number;
  70826. /**
  70827. * Represents the blur intensity for the blurred part of the depth of field effect
  70828. */
  70829. depthOfFieldBlurWidth: number;
  70830. /**
  70831. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70832. */
  70833. get motionStrength(): number;
  70834. /**
  70835. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70836. */
  70837. set motionStrength(strength: number);
  70838. /**
  70839. * Gets wether or not the motion blur post-process is object based or screen based.
  70840. */
  70841. get objectBasedMotionBlur(): boolean;
  70842. /**
  70843. * Sets wether or not the motion blur post-process should be object based or screen based
  70844. */
  70845. set objectBasedMotionBlur(value: boolean);
  70846. /**
  70847. * List of animations for the pipeline (IAnimatable implementation)
  70848. */
  70849. animations: Animation[];
  70850. /**
  70851. * Private members
  70852. */
  70853. private _scene;
  70854. private _currentDepthOfFieldSource;
  70855. private _basePostProcess;
  70856. private _fixedExposure;
  70857. private _currentExposure;
  70858. private _hdrAutoExposure;
  70859. private _hdrCurrentLuminance;
  70860. private _motionStrength;
  70861. private _isObjectBasedMotionBlur;
  70862. private _floatTextureType;
  70863. private _camerasToBeAttached;
  70864. private _ratio;
  70865. private _bloomEnabled;
  70866. private _depthOfFieldEnabled;
  70867. private _vlsEnabled;
  70868. private _lensFlareEnabled;
  70869. private _hdrEnabled;
  70870. private _motionBlurEnabled;
  70871. private _fxaaEnabled;
  70872. private _screenSpaceReflectionsEnabled;
  70873. private _motionBlurSamples;
  70874. private _volumetricLightStepsCount;
  70875. private _samples;
  70876. /**
  70877. * @ignore
  70878. * Specifies if the bloom pipeline is enabled
  70879. */
  70880. get BloomEnabled(): boolean;
  70881. set BloomEnabled(enabled: boolean);
  70882. /**
  70883. * @ignore
  70884. * Specifies if the depth of field pipeline is enabed
  70885. */
  70886. get DepthOfFieldEnabled(): boolean;
  70887. set DepthOfFieldEnabled(enabled: boolean);
  70888. /**
  70889. * @ignore
  70890. * Specifies if the lens flare pipeline is enabed
  70891. */
  70892. get LensFlareEnabled(): boolean;
  70893. set LensFlareEnabled(enabled: boolean);
  70894. /**
  70895. * @ignore
  70896. * Specifies if the HDR pipeline is enabled
  70897. */
  70898. get HDREnabled(): boolean;
  70899. set HDREnabled(enabled: boolean);
  70900. /**
  70901. * @ignore
  70902. * Specifies if the volumetric lights scattering effect is enabled
  70903. */
  70904. get VLSEnabled(): boolean;
  70905. set VLSEnabled(enabled: boolean);
  70906. /**
  70907. * @ignore
  70908. * Specifies if the motion blur effect is enabled
  70909. */
  70910. get MotionBlurEnabled(): boolean;
  70911. set MotionBlurEnabled(enabled: boolean);
  70912. /**
  70913. * Specifies if anti-aliasing is enabled
  70914. */
  70915. get fxaaEnabled(): boolean;
  70916. set fxaaEnabled(enabled: boolean);
  70917. /**
  70918. * Specifies if screen space reflections are enabled.
  70919. */
  70920. get screenSpaceReflectionsEnabled(): boolean;
  70921. set screenSpaceReflectionsEnabled(enabled: boolean);
  70922. /**
  70923. * Specifies the number of steps used to calculate the volumetric lights
  70924. * Typically in interval [50, 200]
  70925. */
  70926. get volumetricLightStepsCount(): number;
  70927. set volumetricLightStepsCount(count: number);
  70928. /**
  70929. * Specifies the number of samples used for the motion blur effect
  70930. * Typically in interval [16, 64]
  70931. */
  70932. get motionBlurSamples(): number;
  70933. set motionBlurSamples(samples: number);
  70934. /**
  70935. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70936. */
  70937. get samples(): number;
  70938. set samples(sampleCount: number);
  70939. /**
  70940. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70941. * @constructor
  70942. * @param name The rendering pipeline name
  70943. * @param scene The scene linked to this pipeline
  70944. * @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)
  70945. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70946. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70947. */
  70948. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70949. private _buildPipeline;
  70950. private _createDownSampleX4PostProcess;
  70951. private _createBrightPassPostProcess;
  70952. private _createBlurPostProcesses;
  70953. private _createTextureAdderPostProcess;
  70954. private _createVolumetricLightPostProcess;
  70955. private _createLuminancePostProcesses;
  70956. private _createHdrPostProcess;
  70957. private _createLensFlarePostProcess;
  70958. private _createDepthOfFieldPostProcess;
  70959. private _createMotionBlurPostProcess;
  70960. private _getDepthTexture;
  70961. private _disposePostProcesses;
  70962. /**
  70963. * Dispose of the pipeline and stop all post processes
  70964. */
  70965. dispose(): void;
  70966. /**
  70967. * Serialize the rendering pipeline (Used when exporting)
  70968. * @returns the serialized object
  70969. */
  70970. serialize(): any;
  70971. /**
  70972. * Parse the serialized pipeline
  70973. * @param source Source pipeline.
  70974. * @param scene The scene to load the pipeline to.
  70975. * @param rootUrl The URL of the serialized pipeline.
  70976. * @returns An instantiated pipeline from the serialized object.
  70977. */
  70978. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70979. /**
  70980. * Luminance steps
  70981. */
  70982. static LuminanceSteps: number;
  70983. }
  70984. }
  70985. declare module BABYLON {
  70986. /** @hidden */
  70987. export var stereoscopicInterlacePixelShader: {
  70988. name: string;
  70989. shader: string;
  70990. };
  70991. }
  70992. declare module BABYLON {
  70993. /**
  70994. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70995. */
  70996. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70997. private _stepSize;
  70998. private _passedProcess;
  70999. /**
  71000. * Initializes a StereoscopicInterlacePostProcessI
  71001. * @param name The name of the effect.
  71002. * @param rigCameras The rig cameras to be appled to the post process
  71003. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71004. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71006. * @param engine The engine which the post process will be applied. (default: current engine)
  71007. * @param reusable If the post process can be reused on the same frame. (default: false)
  71008. */
  71009. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71010. }
  71011. /**
  71012. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71013. */
  71014. export class StereoscopicInterlacePostProcess extends PostProcess {
  71015. private _stepSize;
  71016. private _passedProcess;
  71017. /**
  71018. * Initializes a StereoscopicInterlacePostProcess
  71019. * @param name The name of the effect.
  71020. * @param rigCameras The rig cameras to be appled to the post process
  71021. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71023. * @param engine The engine which the post process will be applied. (default: current engine)
  71024. * @param reusable If the post process can be reused on the same frame. (default: false)
  71025. */
  71026. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71027. }
  71028. }
  71029. declare module BABYLON {
  71030. /** @hidden */
  71031. export var tonemapPixelShader: {
  71032. name: string;
  71033. shader: string;
  71034. };
  71035. }
  71036. declare module BABYLON {
  71037. /** Defines operator used for tonemapping */
  71038. export enum TonemappingOperator {
  71039. /** Hable */
  71040. Hable = 0,
  71041. /** Reinhard */
  71042. Reinhard = 1,
  71043. /** HejiDawson */
  71044. HejiDawson = 2,
  71045. /** Photographic */
  71046. Photographic = 3
  71047. }
  71048. /**
  71049. * Defines a post process to apply tone mapping
  71050. */
  71051. export class TonemapPostProcess extends PostProcess {
  71052. private _operator;
  71053. /** Defines the required exposure adjustement */
  71054. exposureAdjustment: number;
  71055. /**
  71056. * Creates a new TonemapPostProcess
  71057. * @param name defines the name of the postprocess
  71058. * @param _operator defines the operator to use
  71059. * @param exposureAdjustment defines the required exposure adjustement
  71060. * @param camera defines the camera to use (can be null)
  71061. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71062. * @param engine defines the hosting engine (can be ignore if camera is set)
  71063. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71064. */
  71065. constructor(name: string, _operator: TonemappingOperator,
  71066. /** Defines the required exposure adjustement */
  71067. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71068. }
  71069. }
  71070. declare module BABYLON {
  71071. /** @hidden */
  71072. export var volumetricLightScatteringPixelShader: {
  71073. name: string;
  71074. shader: string;
  71075. };
  71076. }
  71077. declare module BABYLON {
  71078. /** @hidden */
  71079. export var volumetricLightScatteringPassVertexShader: {
  71080. name: string;
  71081. shader: string;
  71082. };
  71083. }
  71084. declare module BABYLON {
  71085. /** @hidden */
  71086. export var volumetricLightScatteringPassPixelShader: {
  71087. name: string;
  71088. shader: string;
  71089. };
  71090. }
  71091. declare module BABYLON {
  71092. /**
  71093. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71094. */
  71095. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71096. private _volumetricLightScatteringPass;
  71097. private _volumetricLightScatteringRTT;
  71098. private _viewPort;
  71099. private _screenCoordinates;
  71100. private _cachedDefines;
  71101. /**
  71102. * If not undefined, the mesh position is computed from the attached node position
  71103. */
  71104. attachedNode: {
  71105. position: Vector3;
  71106. };
  71107. /**
  71108. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71109. */
  71110. customMeshPosition: Vector3;
  71111. /**
  71112. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71113. */
  71114. useCustomMeshPosition: boolean;
  71115. /**
  71116. * If the post-process should inverse the light scattering direction
  71117. */
  71118. invert: boolean;
  71119. /**
  71120. * The internal mesh used by the post-process
  71121. */
  71122. mesh: Mesh;
  71123. /**
  71124. * @hidden
  71125. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71126. */
  71127. get useDiffuseColor(): boolean;
  71128. set useDiffuseColor(useDiffuseColor: boolean);
  71129. /**
  71130. * Array containing the excluded meshes not rendered in the internal pass
  71131. */
  71132. excludedMeshes: AbstractMesh[];
  71133. /**
  71134. * Controls the overall intensity of the post-process
  71135. */
  71136. exposure: number;
  71137. /**
  71138. * Dissipates each sample's contribution in range [0, 1]
  71139. */
  71140. decay: number;
  71141. /**
  71142. * Controls the overall intensity of each sample
  71143. */
  71144. weight: number;
  71145. /**
  71146. * Controls the density of each sample
  71147. */
  71148. density: number;
  71149. /**
  71150. * @constructor
  71151. * @param name The post-process name
  71152. * @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)
  71153. * @param camera The camera that the post-process will be attached to
  71154. * @param mesh The mesh used to create the light scattering
  71155. * @param samples The post-process quality, default 100
  71156. * @param samplingModeThe post-process filtering mode
  71157. * @param engine The babylon engine
  71158. * @param reusable If the post-process is reusable
  71159. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71160. */
  71161. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71162. /**
  71163. * Returns the string "VolumetricLightScatteringPostProcess"
  71164. * @returns "VolumetricLightScatteringPostProcess"
  71165. */
  71166. getClassName(): string;
  71167. private _isReady;
  71168. /**
  71169. * Sets the new light position for light scattering effect
  71170. * @param position The new custom light position
  71171. */
  71172. setCustomMeshPosition(position: Vector3): void;
  71173. /**
  71174. * Returns the light position for light scattering effect
  71175. * @return Vector3 The custom light position
  71176. */
  71177. getCustomMeshPosition(): Vector3;
  71178. /**
  71179. * Disposes the internal assets and detaches the post-process from the camera
  71180. */
  71181. dispose(camera: Camera): void;
  71182. /**
  71183. * Returns the render target texture used by the post-process
  71184. * @return the render target texture used by the post-process
  71185. */
  71186. getPass(): RenderTargetTexture;
  71187. private _meshExcluded;
  71188. private _createPass;
  71189. private _updateMeshScreenCoordinates;
  71190. /**
  71191. * Creates a default mesh for the Volumeric Light Scattering post-process
  71192. * @param name The mesh name
  71193. * @param scene The scene where to create the mesh
  71194. * @return the default mesh
  71195. */
  71196. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71197. }
  71198. }
  71199. declare module BABYLON {
  71200. /** @hidden */
  71201. export var screenSpaceCurvaturePixelShader: {
  71202. name: string;
  71203. shader: string;
  71204. };
  71205. }
  71206. declare module BABYLON {
  71207. /**
  71208. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71209. */
  71210. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71211. /**
  71212. * Defines how much ridge the curvature effect displays.
  71213. */
  71214. ridge: number;
  71215. /**
  71216. * Defines how much valley the curvature effect displays.
  71217. */
  71218. valley: number;
  71219. private _geometryBufferRenderer;
  71220. /**
  71221. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71222. * @param name The name of the effect.
  71223. * @param scene The scene containing the objects to blur according to their velocity.
  71224. * @param options The required width/height ratio to downsize to before computing the render pass.
  71225. * @param camera The camera to apply the render pass to.
  71226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71227. * @param engine The engine which the post process will be applied. (default: current engine)
  71228. * @param reusable If the post process can be reused on the same frame. (default: false)
  71229. * @param textureType Type of textures used when performing the post process. (default: 0)
  71230. * @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)
  71231. */
  71232. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71233. /**
  71234. * Support test.
  71235. */
  71236. static get IsSupported(): boolean;
  71237. }
  71238. }
  71239. declare module BABYLON {
  71240. interface Scene {
  71241. /** @hidden (Backing field) */
  71242. _boundingBoxRenderer: BoundingBoxRenderer;
  71243. /** @hidden (Backing field) */
  71244. _forceShowBoundingBoxes: boolean;
  71245. /**
  71246. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71247. */
  71248. forceShowBoundingBoxes: boolean;
  71249. /**
  71250. * Gets the bounding box renderer associated with the scene
  71251. * @returns a BoundingBoxRenderer
  71252. */
  71253. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71254. }
  71255. interface AbstractMesh {
  71256. /** @hidden (Backing field) */
  71257. _showBoundingBox: boolean;
  71258. /**
  71259. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71260. */
  71261. showBoundingBox: boolean;
  71262. }
  71263. /**
  71264. * Component responsible of rendering the bounding box of the meshes in a scene.
  71265. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71266. */
  71267. export class BoundingBoxRenderer implements ISceneComponent {
  71268. /**
  71269. * The component name helpfull to identify the component in the list of scene components.
  71270. */
  71271. readonly name: string;
  71272. /**
  71273. * The scene the component belongs to.
  71274. */
  71275. scene: Scene;
  71276. /**
  71277. * Color of the bounding box lines placed in front of an object
  71278. */
  71279. frontColor: Color3;
  71280. /**
  71281. * Color of the bounding box lines placed behind an object
  71282. */
  71283. backColor: Color3;
  71284. /**
  71285. * Defines if the renderer should show the back lines or not
  71286. */
  71287. showBackLines: boolean;
  71288. /**
  71289. * Observable raised before rendering a bounding box
  71290. */
  71291. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71292. /**
  71293. * Observable raised after rendering a bounding box
  71294. */
  71295. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71296. /**
  71297. * @hidden
  71298. */
  71299. renderList: SmartArray<BoundingBox>;
  71300. private _colorShader;
  71301. private _vertexBuffers;
  71302. private _indexBuffer;
  71303. private _fillIndexBuffer;
  71304. private _fillIndexData;
  71305. /**
  71306. * Instantiates a new bounding box renderer in a scene.
  71307. * @param scene the scene the renderer renders in
  71308. */
  71309. constructor(scene: Scene);
  71310. /**
  71311. * Registers the component in a given scene
  71312. */
  71313. register(): void;
  71314. private _evaluateSubMesh;
  71315. private _activeMesh;
  71316. private _prepareRessources;
  71317. private _createIndexBuffer;
  71318. /**
  71319. * Rebuilds the elements related to this component in case of
  71320. * context lost for instance.
  71321. */
  71322. rebuild(): void;
  71323. /**
  71324. * @hidden
  71325. */
  71326. reset(): void;
  71327. /**
  71328. * Render the bounding boxes of a specific rendering group
  71329. * @param renderingGroupId defines the rendering group to render
  71330. */
  71331. render(renderingGroupId: number): void;
  71332. /**
  71333. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71334. * @param mesh Define the mesh to render the occlusion bounding box for
  71335. */
  71336. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71337. /**
  71338. * Dispose and release the resources attached to this renderer.
  71339. */
  71340. dispose(): void;
  71341. }
  71342. }
  71343. declare module BABYLON {
  71344. interface Scene {
  71345. /** @hidden (Backing field) */
  71346. _depthRenderer: {
  71347. [id: string]: DepthRenderer;
  71348. };
  71349. /**
  71350. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71351. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71352. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71353. * @returns the created depth renderer
  71354. */
  71355. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71356. /**
  71357. * Disables a depth renderer for a given camera
  71358. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71359. */
  71360. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71361. }
  71362. /**
  71363. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71364. * in several rendering techniques.
  71365. */
  71366. export class DepthRendererSceneComponent implements ISceneComponent {
  71367. /**
  71368. * The component name helpfull to identify the component in the list of scene components.
  71369. */
  71370. readonly name: string;
  71371. /**
  71372. * The scene the component belongs to.
  71373. */
  71374. scene: Scene;
  71375. /**
  71376. * Creates a new instance of the component for the given scene
  71377. * @param scene Defines the scene to register the component in
  71378. */
  71379. constructor(scene: Scene);
  71380. /**
  71381. * Registers the component in a given scene
  71382. */
  71383. register(): void;
  71384. /**
  71385. * Rebuilds the elements related to this component in case of
  71386. * context lost for instance.
  71387. */
  71388. rebuild(): void;
  71389. /**
  71390. * Disposes the component and the associated ressources
  71391. */
  71392. dispose(): void;
  71393. private _gatherRenderTargets;
  71394. private _gatherActiveCameraRenderTargets;
  71395. }
  71396. }
  71397. declare module BABYLON {
  71398. interface AbstractScene {
  71399. /** @hidden (Backing field) */
  71400. _prePassRenderer: Nullable<PrePassRenderer>;
  71401. /**
  71402. * Gets or Sets the current prepass renderer associated to the scene.
  71403. */
  71404. prePassRenderer: Nullable<PrePassRenderer>;
  71405. /**
  71406. * Enables the prepass and associates it with the scene
  71407. * @returns the PrePassRenderer
  71408. */
  71409. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71410. /**
  71411. * Disables the prepass associated with the scene
  71412. */
  71413. disablePrePassRenderer(): void;
  71414. }
  71415. /**
  71416. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71417. * in several rendering techniques.
  71418. */
  71419. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71420. /**
  71421. * The component name helpful to identify the component in the list of scene components.
  71422. */
  71423. readonly name: string;
  71424. /**
  71425. * The scene the component belongs to.
  71426. */
  71427. scene: Scene;
  71428. /**
  71429. * Creates a new instance of the component for the given scene
  71430. * @param scene Defines the scene to register the component in
  71431. */
  71432. constructor(scene: Scene);
  71433. /**
  71434. * Registers the component in a given scene
  71435. */
  71436. register(): void;
  71437. private _beforeCameraDraw;
  71438. private _afterCameraDraw;
  71439. private _beforeClearStage;
  71440. /**
  71441. * Serializes the component data to the specified json object
  71442. * @param serializationObject The object to serialize to
  71443. */
  71444. serialize(serializationObject: any): void;
  71445. /**
  71446. * Adds all the elements from the container to the scene
  71447. * @param container the container holding the elements
  71448. */
  71449. addFromContainer(container: AbstractScene): void;
  71450. /**
  71451. * Removes all the elements in the container from the scene
  71452. * @param container contains the elements to remove
  71453. * @param dispose if the removed element should be disposed (default: false)
  71454. */
  71455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71456. /**
  71457. * Rebuilds the elements related to this component in case of
  71458. * context lost for instance.
  71459. */
  71460. rebuild(): void;
  71461. /**
  71462. * Disposes the component and the associated ressources
  71463. */
  71464. dispose(): void;
  71465. }
  71466. }
  71467. declare module BABYLON {
  71468. /** @hidden */
  71469. export var outlinePixelShader: {
  71470. name: string;
  71471. shader: string;
  71472. };
  71473. }
  71474. declare module BABYLON {
  71475. /** @hidden */
  71476. export var outlineVertexShader: {
  71477. name: string;
  71478. shader: string;
  71479. };
  71480. }
  71481. declare module BABYLON {
  71482. interface Scene {
  71483. /** @hidden */
  71484. _outlineRenderer: OutlineRenderer;
  71485. /**
  71486. * Gets the outline renderer associated with the scene
  71487. * @returns a OutlineRenderer
  71488. */
  71489. getOutlineRenderer(): OutlineRenderer;
  71490. }
  71491. interface AbstractMesh {
  71492. /** @hidden (Backing field) */
  71493. _renderOutline: boolean;
  71494. /**
  71495. * Gets or sets a boolean indicating if the outline must be rendered as well
  71496. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71497. */
  71498. renderOutline: boolean;
  71499. /** @hidden (Backing field) */
  71500. _renderOverlay: boolean;
  71501. /**
  71502. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71503. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71504. */
  71505. renderOverlay: boolean;
  71506. }
  71507. /**
  71508. * This class is responsible to draw bothe outline/overlay of meshes.
  71509. * It should not be used directly but through the available method on mesh.
  71510. */
  71511. export class OutlineRenderer implements ISceneComponent {
  71512. /**
  71513. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71514. */
  71515. private static _StencilReference;
  71516. /**
  71517. * The name of the component. Each component must have a unique name.
  71518. */
  71519. name: string;
  71520. /**
  71521. * The scene the component belongs to.
  71522. */
  71523. scene: Scene;
  71524. /**
  71525. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71526. */
  71527. zOffset: number;
  71528. private _engine;
  71529. private _effect;
  71530. private _cachedDefines;
  71531. private _savedDepthWrite;
  71532. /**
  71533. * Instantiates a new outline renderer. (There could be only one per scene).
  71534. * @param scene Defines the scene it belongs to
  71535. */
  71536. constructor(scene: Scene);
  71537. /**
  71538. * Register the component to one instance of a scene.
  71539. */
  71540. register(): void;
  71541. /**
  71542. * Rebuilds the elements related to this component in case of
  71543. * context lost for instance.
  71544. */
  71545. rebuild(): void;
  71546. /**
  71547. * Disposes the component and the associated ressources.
  71548. */
  71549. dispose(): void;
  71550. /**
  71551. * Renders the outline in the canvas.
  71552. * @param subMesh Defines the sumesh to render
  71553. * @param batch Defines the batch of meshes in case of instances
  71554. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71555. */
  71556. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71557. /**
  71558. * Returns whether or not the outline renderer is ready for a given submesh.
  71559. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71560. * @param subMesh Defines the submesh to check readyness for
  71561. * @param useInstances Defines wheter wee are trying to render instances or not
  71562. * @returns true if ready otherwise false
  71563. */
  71564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71565. private _beforeRenderingMesh;
  71566. private _afterRenderingMesh;
  71567. }
  71568. }
  71569. declare module BABYLON {
  71570. /**
  71571. * Defines the basic options interface of a Sprite Frame Source Size.
  71572. */
  71573. export interface ISpriteJSONSpriteSourceSize {
  71574. /**
  71575. * number of the original width of the Frame
  71576. */
  71577. w: number;
  71578. /**
  71579. * number of the original height of the Frame
  71580. */
  71581. h: number;
  71582. }
  71583. /**
  71584. * Defines the basic options interface of a Sprite Frame Data.
  71585. */
  71586. export interface ISpriteJSONSpriteFrameData {
  71587. /**
  71588. * number of the x offset of the Frame
  71589. */
  71590. x: number;
  71591. /**
  71592. * number of the y offset of the Frame
  71593. */
  71594. y: number;
  71595. /**
  71596. * number of the width of the Frame
  71597. */
  71598. w: number;
  71599. /**
  71600. * number of the height of the Frame
  71601. */
  71602. h: number;
  71603. }
  71604. /**
  71605. * Defines the basic options interface of a JSON Sprite.
  71606. */
  71607. export interface ISpriteJSONSprite {
  71608. /**
  71609. * string name of the Frame
  71610. */
  71611. filename: string;
  71612. /**
  71613. * ISpriteJSONSpriteFrame basic object of the frame data
  71614. */
  71615. frame: ISpriteJSONSpriteFrameData;
  71616. /**
  71617. * boolean to flag is the frame was rotated.
  71618. */
  71619. rotated: boolean;
  71620. /**
  71621. * boolean to flag is the frame was trimmed.
  71622. */
  71623. trimmed: boolean;
  71624. /**
  71625. * ISpriteJSONSpriteFrame basic object of the source data
  71626. */
  71627. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71628. /**
  71629. * ISpriteJSONSpriteFrame basic object of the source data
  71630. */
  71631. sourceSize: ISpriteJSONSpriteSourceSize;
  71632. }
  71633. /**
  71634. * Defines the basic options interface of a JSON atlas.
  71635. */
  71636. export interface ISpriteJSONAtlas {
  71637. /**
  71638. * Array of objects that contain the frame data.
  71639. */
  71640. frames: Array<ISpriteJSONSprite>;
  71641. /**
  71642. * object basic object containing the sprite meta data.
  71643. */
  71644. meta?: object;
  71645. }
  71646. }
  71647. declare module BABYLON {
  71648. /** @hidden */
  71649. export var spriteMapPixelShader: {
  71650. name: string;
  71651. shader: string;
  71652. };
  71653. }
  71654. declare module BABYLON {
  71655. /** @hidden */
  71656. export var spriteMapVertexShader: {
  71657. name: string;
  71658. shader: string;
  71659. };
  71660. }
  71661. declare module BABYLON {
  71662. /**
  71663. * Defines the basic options interface of a SpriteMap
  71664. */
  71665. export interface ISpriteMapOptions {
  71666. /**
  71667. * Vector2 of the number of cells in the grid.
  71668. */
  71669. stageSize?: Vector2;
  71670. /**
  71671. * Vector2 of the size of the output plane in World Units.
  71672. */
  71673. outputSize?: Vector2;
  71674. /**
  71675. * Vector3 of the position of the output plane in World Units.
  71676. */
  71677. outputPosition?: Vector3;
  71678. /**
  71679. * Vector3 of the rotation of the output plane.
  71680. */
  71681. outputRotation?: Vector3;
  71682. /**
  71683. * number of layers that the system will reserve in resources.
  71684. */
  71685. layerCount?: number;
  71686. /**
  71687. * number of max animation frames a single cell will reserve in resources.
  71688. */
  71689. maxAnimationFrames?: number;
  71690. /**
  71691. * number cell index of the base tile when the system compiles.
  71692. */
  71693. baseTile?: number;
  71694. /**
  71695. * boolean flip the sprite after its been repositioned by the framing data.
  71696. */
  71697. flipU?: boolean;
  71698. /**
  71699. * Vector3 scalar of the global RGB values of the SpriteMap.
  71700. */
  71701. colorMultiply?: Vector3;
  71702. }
  71703. /**
  71704. * Defines the IDisposable interface in order to be cleanable from resources.
  71705. */
  71706. export interface ISpriteMap extends IDisposable {
  71707. /**
  71708. * String name of the SpriteMap.
  71709. */
  71710. name: string;
  71711. /**
  71712. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71713. */
  71714. atlasJSON: ISpriteJSONAtlas;
  71715. /**
  71716. * Texture of the SpriteMap.
  71717. */
  71718. spriteSheet: Texture;
  71719. /**
  71720. * The parameters to initialize the SpriteMap with.
  71721. */
  71722. options: ISpriteMapOptions;
  71723. }
  71724. /**
  71725. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71726. */
  71727. export class SpriteMap implements ISpriteMap {
  71728. /** The Name of the spriteMap */
  71729. name: string;
  71730. /** The JSON file with the frame and meta data */
  71731. atlasJSON: ISpriteJSONAtlas;
  71732. /** The systems Sprite Sheet Texture */
  71733. spriteSheet: Texture;
  71734. /** Arguments passed with the Constructor */
  71735. options: ISpriteMapOptions;
  71736. /** Public Sprite Storage array, parsed from atlasJSON */
  71737. sprites: Array<ISpriteJSONSprite>;
  71738. /** Returns the Number of Sprites in the System */
  71739. get spriteCount(): number;
  71740. /** Returns the Position of Output Plane*/
  71741. get position(): Vector3;
  71742. /** Returns the Position of Output Plane*/
  71743. set position(v: Vector3);
  71744. /** Returns the Rotation of Output Plane*/
  71745. get rotation(): Vector3;
  71746. /** Returns the Rotation of Output Plane*/
  71747. set rotation(v: Vector3);
  71748. /** Sets the AnimationMap*/
  71749. get animationMap(): RawTexture;
  71750. /** Sets the AnimationMap*/
  71751. set animationMap(v: RawTexture);
  71752. /** Scene that the SpriteMap was created in */
  71753. private _scene;
  71754. /** Texture Buffer of Float32 that holds tile frame data*/
  71755. private _frameMap;
  71756. /** Texture Buffers of Float32 that holds tileMap data*/
  71757. private _tileMaps;
  71758. /** Texture Buffer of Float32 that holds Animation Data*/
  71759. private _animationMap;
  71760. /** Custom ShaderMaterial Central to the System*/
  71761. private _material;
  71762. /** Custom ShaderMaterial Central to the System*/
  71763. private _output;
  71764. /** Systems Time Ticker*/
  71765. private _time;
  71766. /**
  71767. * Creates a new SpriteMap
  71768. * @param name defines the SpriteMaps Name
  71769. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71770. * @param spriteSheet is the Texture that the Sprites are on.
  71771. * @param options a basic deployment configuration
  71772. * @param scene The Scene that the map is deployed on
  71773. */
  71774. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71775. /**
  71776. * Returns tileID location
  71777. * @returns Vector2 the cell position ID
  71778. */
  71779. getTileID(): Vector2;
  71780. /**
  71781. * Gets the UV location of the mouse over the SpriteMap.
  71782. * @returns Vector2 the UV position of the mouse interaction
  71783. */
  71784. getMousePosition(): Vector2;
  71785. /**
  71786. * Creates the "frame" texture Buffer
  71787. * -------------------------------------
  71788. * Structure of frames
  71789. * "filename": "Falling-Water-2.png",
  71790. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71791. * "rotated": true,
  71792. * "trimmed": true,
  71793. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71794. * "sourceSize": {"w":32,"h":32}
  71795. * @returns RawTexture of the frameMap
  71796. */
  71797. private _createFrameBuffer;
  71798. /**
  71799. * Creates the tileMap texture Buffer
  71800. * @param buffer normally and array of numbers, or a false to generate from scratch
  71801. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71802. * @returns RawTexture of the tileMap
  71803. */
  71804. private _createTileBuffer;
  71805. /**
  71806. * Modifies the data of the tileMaps
  71807. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71808. * @param pos is the iVector2 Coordinates of the Tile
  71809. * @param tile The SpriteIndex of the new Tile
  71810. */
  71811. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71812. /**
  71813. * Creates the animationMap texture Buffer
  71814. * @param buffer normally and array of numbers, or a false to generate from scratch
  71815. * @returns RawTexture of the animationMap
  71816. */
  71817. private _createTileAnimationBuffer;
  71818. /**
  71819. * Modifies the data of the animationMap
  71820. * @param cellID is the Index of the Sprite
  71821. * @param _frame is the target Animation frame
  71822. * @param toCell is the Target Index of the next frame of the animation
  71823. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71824. * @param speed is a global scalar of the time variable on the map.
  71825. */
  71826. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71827. /**
  71828. * Exports the .tilemaps file
  71829. */
  71830. saveTileMaps(): void;
  71831. /**
  71832. * Imports the .tilemaps file
  71833. * @param url of the .tilemaps file
  71834. */
  71835. loadTileMaps(url: string): void;
  71836. /**
  71837. * Release associated resources
  71838. */
  71839. dispose(): void;
  71840. }
  71841. }
  71842. declare module BABYLON {
  71843. /**
  71844. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71845. * @see https://doc.babylonjs.com/babylon101/sprites
  71846. */
  71847. export class SpritePackedManager extends SpriteManager {
  71848. /** defines the packed manager's name */
  71849. name: string;
  71850. /**
  71851. * Creates a new sprite manager from a packed sprite sheet
  71852. * @param name defines the manager's name
  71853. * @param imgUrl defines the sprite sheet url
  71854. * @param capacity defines the maximum allowed number of sprites
  71855. * @param scene defines the hosting scene
  71856. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71857. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71858. * @param samplingMode defines the smapling mode to use with spritesheet
  71859. * @param fromPacked set to true; do not alter
  71860. */
  71861. constructor(
  71862. /** defines the packed manager's name */
  71863. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71864. }
  71865. }
  71866. declare module BABYLON {
  71867. /**
  71868. * Defines the list of states available for a task inside a AssetsManager
  71869. */
  71870. export enum AssetTaskState {
  71871. /**
  71872. * Initialization
  71873. */
  71874. INIT = 0,
  71875. /**
  71876. * Running
  71877. */
  71878. RUNNING = 1,
  71879. /**
  71880. * Done
  71881. */
  71882. DONE = 2,
  71883. /**
  71884. * Error
  71885. */
  71886. ERROR = 3
  71887. }
  71888. /**
  71889. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71890. */
  71891. export abstract class AbstractAssetTask {
  71892. /**
  71893. * Task name
  71894. */ name: string;
  71895. /**
  71896. * Callback called when the task is successful
  71897. */
  71898. onSuccess: (task: any) => void;
  71899. /**
  71900. * Callback called when the task is not successful
  71901. */
  71902. onError: (task: any, message?: string, exception?: any) => void;
  71903. /**
  71904. * Creates a new AssetsManager
  71905. * @param name defines the name of the task
  71906. */
  71907. constructor(
  71908. /**
  71909. * Task name
  71910. */ name: string);
  71911. private _isCompleted;
  71912. private _taskState;
  71913. private _errorObject;
  71914. /**
  71915. * Get if the task is completed
  71916. */
  71917. get isCompleted(): boolean;
  71918. /**
  71919. * Gets the current state of the task
  71920. */
  71921. get taskState(): AssetTaskState;
  71922. /**
  71923. * Gets the current error object (if task is in error)
  71924. */
  71925. get errorObject(): {
  71926. message?: string;
  71927. exception?: any;
  71928. };
  71929. /**
  71930. * Internal only
  71931. * @hidden
  71932. */
  71933. _setErrorObject(message?: string, exception?: any): void;
  71934. /**
  71935. * Execute the current task
  71936. * @param scene defines the scene where you want your assets to be loaded
  71937. * @param onSuccess is a callback called when the task is successfully executed
  71938. * @param onError is a callback called if an error occurs
  71939. */
  71940. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71941. /**
  71942. * Execute the current task
  71943. * @param scene defines the scene where you want your assets to be loaded
  71944. * @param onSuccess is a callback called when the task is successfully executed
  71945. * @param onError is a callback called if an error occurs
  71946. */
  71947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71948. /**
  71949. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71950. * This can be used with failed tasks that have the reason for failure fixed.
  71951. */
  71952. reset(): void;
  71953. private onErrorCallback;
  71954. private onDoneCallback;
  71955. }
  71956. /**
  71957. * Define the interface used by progress events raised during assets loading
  71958. */
  71959. export interface IAssetsProgressEvent {
  71960. /**
  71961. * Defines the number of remaining tasks to process
  71962. */
  71963. remainingCount: number;
  71964. /**
  71965. * Defines the total number of tasks
  71966. */
  71967. totalCount: number;
  71968. /**
  71969. * Defines the task that was just processed
  71970. */
  71971. task: AbstractAssetTask;
  71972. }
  71973. /**
  71974. * Class used to share progress information about assets loading
  71975. */
  71976. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71977. /**
  71978. * Defines the number of remaining tasks to process
  71979. */
  71980. remainingCount: number;
  71981. /**
  71982. * Defines the total number of tasks
  71983. */
  71984. totalCount: number;
  71985. /**
  71986. * Defines the task that was just processed
  71987. */
  71988. task: AbstractAssetTask;
  71989. /**
  71990. * Creates a AssetsProgressEvent
  71991. * @param remainingCount defines the number of remaining tasks to process
  71992. * @param totalCount defines the total number of tasks
  71993. * @param task defines the task that was just processed
  71994. */
  71995. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71996. }
  71997. /**
  71998. * Define a task used by AssetsManager to load assets into a container
  71999. */
  72000. export class ContainerAssetTask extends AbstractAssetTask {
  72001. /**
  72002. * Defines the name of the task
  72003. */
  72004. name: string;
  72005. /**
  72006. * Defines the list of mesh's names you want to load
  72007. */
  72008. meshesNames: any;
  72009. /**
  72010. * Defines the root url to use as a base to load your meshes and associated resources
  72011. */
  72012. rootUrl: string;
  72013. /**
  72014. * Defines the filename or File of the scene to load from
  72015. */
  72016. sceneFilename: string | File;
  72017. /**
  72018. * Get the loaded asset container
  72019. */
  72020. loadedContainer: AssetContainer;
  72021. /**
  72022. * Gets the list of loaded meshes
  72023. */
  72024. loadedMeshes: Array<AbstractMesh>;
  72025. /**
  72026. * Gets the list of loaded particle systems
  72027. */
  72028. loadedParticleSystems: Array<IParticleSystem>;
  72029. /**
  72030. * Gets the list of loaded skeletons
  72031. */
  72032. loadedSkeletons: Array<Skeleton>;
  72033. /**
  72034. * Gets the list of loaded animation groups
  72035. */
  72036. loadedAnimationGroups: Array<AnimationGroup>;
  72037. /**
  72038. * Callback called when the task is successful
  72039. */
  72040. onSuccess: (task: ContainerAssetTask) => void;
  72041. /**
  72042. * Callback called when the task is successful
  72043. */
  72044. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72045. /**
  72046. * Creates a new ContainerAssetTask
  72047. * @param name defines the name of the task
  72048. * @param meshesNames defines the list of mesh's names you want to load
  72049. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72050. * @param sceneFilename defines the filename or File of the scene to load from
  72051. */
  72052. constructor(
  72053. /**
  72054. * Defines the name of the task
  72055. */
  72056. name: string,
  72057. /**
  72058. * Defines the list of mesh's names you want to load
  72059. */
  72060. meshesNames: any,
  72061. /**
  72062. * Defines the root url to use as a base to load your meshes and associated resources
  72063. */
  72064. rootUrl: string,
  72065. /**
  72066. * Defines the filename or File of the scene to load from
  72067. */
  72068. sceneFilename: string | File);
  72069. /**
  72070. * Execute the current task
  72071. * @param scene defines the scene where you want your assets to be loaded
  72072. * @param onSuccess is a callback called when the task is successfully executed
  72073. * @param onError is a callback called if an error occurs
  72074. */
  72075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72076. }
  72077. /**
  72078. * Define a task used by AssetsManager to load meshes
  72079. */
  72080. export class MeshAssetTask extends AbstractAssetTask {
  72081. /**
  72082. * Defines the name of the task
  72083. */
  72084. name: string;
  72085. /**
  72086. * Defines the list of mesh's names you want to load
  72087. */
  72088. meshesNames: any;
  72089. /**
  72090. * Defines the root url to use as a base to load your meshes and associated resources
  72091. */
  72092. rootUrl: string;
  72093. /**
  72094. * Defines the filename or File of the scene to load from
  72095. */
  72096. sceneFilename: string | File;
  72097. /**
  72098. * Gets the list of loaded meshes
  72099. */
  72100. loadedMeshes: Array<AbstractMesh>;
  72101. /**
  72102. * Gets the list of loaded particle systems
  72103. */
  72104. loadedParticleSystems: Array<IParticleSystem>;
  72105. /**
  72106. * Gets the list of loaded skeletons
  72107. */
  72108. loadedSkeletons: Array<Skeleton>;
  72109. /**
  72110. * Gets the list of loaded animation groups
  72111. */
  72112. loadedAnimationGroups: Array<AnimationGroup>;
  72113. /**
  72114. * Callback called when the task is successful
  72115. */
  72116. onSuccess: (task: MeshAssetTask) => void;
  72117. /**
  72118. * Callback called when the task is successful
  72119. */
  72120. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72121. /**
  72122. * Creates a new MeshAssetTask
  72123. * @param name defines the name of the task
  72124. * @param meshesNames defines the list of mesh's names you want to load
  72125. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72126. * @param sceneFilename defines the filename or File of the scene to load from
  72127. */
  72128. constructor(
  72129. /**
  72130. * Defines the name of the task
  72131. */
  72132. name: string,
  72133. /**
  72134. * Defines the list of mesh's names you want to load
  72135. */
  72136. meshesNames: any,
  72137. /**
  72138. * Defines the root url to use as a base to load your meshes and associated resources
  72139. */
  72140. rootUrl: string,
  72141. /**
  72142. * Defines the filename or File of the scene to load from
  72143. */
  72144. sceneFilename: string | File);
  72145. /**
  72146. * Execute the current task
  72147. * @param scene defines the scene where you want your assets to be loaded
  72148. * @param onSuccess is a callback called when the task is successfully executed
  72149. * @param onError is a callback called if an error occurs
  72150. */
  72151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72152. }
  72153. /**
  72154. * Define a task used by AssetsManager to load text content
  72155. */
  72156. export class TextFileAssetTask extends AbstractAssetTask {
  72157. /**
  72158. * Defines the name of the task
  72159. */
  72160. name: string;
  72161. /**
  72162. * Defines the location of the file to load
  72163. */
  72164. url: string;
  72165. /**
  72166. * Gets the loaded text string
  72167. */
  72168. text: string;
  72169. /**
  72170. * Callback called when the task is successful
  72171. */
  72172. onSuccess: (task: TextFileAssetTask) => void;
  72173. /**
  72174. * Callback called when the task is successful
  72175. */
  72176. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72177. /**
  72178. * Creates a new TextFileAssetTask object
  72179. * @param name defines the name of the task
  72180. * @param url defines the location of the file to load
  72181. */
  72182. constructor(
  72183. /**
  72184. * Defines the name of the task
  72185. */
  72186. name: string,
  72187. /**
  72188. * Defines the location of the file to load
  72189. */
  72190. url: string);
  72191. /**
  72192. * Execute the current task
  72193. * @param scene defines the scene where you want your assets to be loaded
  72194. * @param onSuccess is a callback called when the task is successfully executed
  72195. * @param onError is a callback called if an error occurs
  72196. */
  72197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72198. }
  72199. /**
  72200. * Define a task used by AssetsManager to load binary data
  72201. */
  72202. export class BinaryFileAssetTask extends AbstractAssetTask {
  72203. /**
  72204. * Defines the name of the task
  72205. */
  72206. name: string;
  72207. /**
  72208. * Defines the location of the file to load
  72209. */
  72210. url: string;
  72211. /**
  72212. * Gets the lodaded data (as an array buffer)
  72213. */
  72214. data: ArrayBuffer;
  72215. /**
  72216. * Callback called when the task is successful
  72217. */
  72218. onSuccess: (task: BinaryFileAssetTask) => void;
  72219. /**
  72220. * Callback called when the task is successful
  72221. */
  72222. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72223. /**
  72224. * Creates a new BinaryFileAssetTask object
  72225. * @param name defines the name of the new task
  72226. * @param url defines the location of the file to load
  72227. */
  72228. constructor(
  72229. /**
  72230. * Defines the name of the task
  72231. */
  72232. name: string,
  72233. /**
  72234. * Defines the location of the file to load
  72235. */
  72236. url: string);
  72237. /**
  72238. * Execute the current task
  72239. * @param scene defines the scene where you want your assets to be loaded
  72240. * @param onSuccess is a callback called when the task is successfully executed
  72241. * @param onError is a callback called if an error occurs
  72242. */
  72243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72244. }
  72245. /**
  72246. * Define a task used by AssetsManager to load images
  72247. */
  72248. export class ImageAssetTask extends AbstractAssetTask {
  72249. /**
  72250. * Defines the name of the task
  72251. */
  72252. name: string;
  72253. /**
  72254. * Defines the location of the image to load
  72255. */
  72256. url: string;
  72257. /**
  72258. * Gets the loaded images
  72259. */
  72260. image: HTMLImageElement;
  72261. /**
  72262. * Callback called when the task is successful
  72263. */
  72264. onSuccess: (task: ImageAssetTask) => void;
  72265. /**
  72266. * Callback called when the task is successful
  72267. */
  72268. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72269. /**
  72270. * Creates a new ImageAssetTask
  72271. * @param name defines the name of the task
  72272. * @param url defines the location of the image to load
  72273. */
  72274. constructor(
  72275. /**
  72276. * Defines the name of the task
  72277. */
  72278. name: string,
  72279. /**
  72280. * Defines the location of the image to load
  72281. */
  72282. url: string);
  72283. /**
  72284. * Execute the current task
  72285. * @param scene defines the scene where you want your assets to be loaded
  72286. * @param onSuccess is a callback called when the task is successfully executed
  72287. * @param onError is a callback called if an error occurs
  72288. */
  72289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72290. }
  72291. /**
  72292. * Defines the interface used by texture loading tasks
  72293. */
  72294. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72295. /**
  72296. * Gets the loaded texture
  72297. */
  72298. texture: TEX;
  72299. }
  72300. /**
  72301. * Define a task used by AssetsManager to load 2D textures
  72302. */
  72303. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72304. /**
  72305. * Defines the name of the task
  72306. */
  72307. name: string;
  72308. /**
  72309. * Defines the location of the file to load
  72310. */
  72311. url: string;
  72312. /**
  72313. * Defines if mipmap should not be generated (default is false)
  72314. */
  72315. noMipmap?: boolean | undefined;
  72316. /**
  72317. * Defines if texture must be inverted on Y axis (default is true)
  72318. */
  72319. invertY: boolean;
  72320. /**
  72321. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72322. */
  72323. samplingMode: number;
  72324. /**
  72325. * Gets the loaded texture
  72326. */
  72327. texture: Texture;
  72328. /**
  72329. * Callback called when the task is successful
  72330. */
  72331. onSuccess: (task: TextureAssetTask) => void;
  72332. /**
  72333. * Callback called when the task is successful
  72334. */
  72335. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72336. /**
  72337. * Creates a new TextureAssetTask object
  72338. * @param name defines the name of the task
  72339. * @param url defines the location of the file to load
  72340. * @param noMipmap defines if mipmap should not be generated (default is false)
  72341. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72342. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72343. */
  72344. constructor(
  72345. /**
  72346. * Defines the name of the task
  72347. */
  72348. name: string,
  72349. /**
  72350. * Defines the location of the file to load
  72351. */
  72352. url: string,
  72353. /**
  72354. * Defines if mipmap should not be generated (default is false)
  72355. */
  72356. noMipmap?: boolean | undefined,
  72357. /**
  72358. * Defines if texture must be inverted on Y axis (default is true)
  72359. */
  72360. invertY?: boolean,
  72361. /**
  72362. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72363. */
  72364. samplingMode?: number);
  72365. /**
  72366. * Execute the current task
  72367. * @param scene defines the scene where you want your assets to be loaded
  72368. * @param onSuccess is a callback called when the task is successfully executed
  72369. * @param onError is a callback called if an error occurs
  72370. */
  72371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72372. }
  72373. /**
  72374. * Define a task used by AssetsManager to load cube textures
  72375. */
  72376. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72377. /**
  72378. * Defines the name of the task
  72379. */
  72380. name: string;
  72381. /**
  72382. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72383. */
  72384. url: string;
  72385. /**
  72386. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72387. */
  72388. extensions?: string[] | undefined;
  72389. /**
  72390. * Defines if mipmaps should not be generated (default is false)
  72391. */
  72392. noMipmap?: boolean | undefined;
  72393. /**
  72394. * Defines the explicit list of files (undefined by default)
  72395. */
  72396. files?: string[] | undefined;
  72397. /**
  72398. * Gets the loaded texture
  72399. */
  72400. texture: CubeTexture;
  72401. /**
  72402. * Callback called when the task is successful
  72403. */
  72404. onSuccess: (task: CubeTextureAssetTask) => void;
  72405. /**
  72406. * Callback called when the task is successful
  72407. */
  72408. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72409. /**
  72410. * Creates a new CubeTextureAssetTask
  72411. * @param name defines the name of the task
  72412. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72413. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72414. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72415. * @param files defines the explicit list of files (undefined by default)
  72416. */
  72417. constructor(
  72418. /**
  72419. * Defines the name of the task
  72420. */
  72421. name: string,
  72422. /**
  72423. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72424. */
  72425. url: string,
  72426. /**
  72427. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72428. */
  72429. extensions?: string[] | undefined,
  72430. /**
  72431. * Defines if mipmaps should not be generated (default is false)
  72432. */
  72433. noMipmap?: boolean | undefined,
  72434. /**
  72435. * Defines the explicit list of files (undefined by default)
  72436. */
  72437. files?: string[] | undefined);
  72438. /**
  72439. * Execute the current task
  72440. * @param scene defines the scene where you want your assets to be loaded
  72441. * @param onSuccess is a callback called when the task is successfully executed
  72442. * @param onError is a callback called if an error occurs
  72443. */
  72444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72445. }
  72446. /**
  72447. * Define a task used by AssetsManager to load HDR cube textures
  72448. */
  72449. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72450. /**
  72451. * Defines the name of the task
  72452. */
  72453. name: string;
  72454. /**
  72455. * Defines the location of the file to load
  72456. */
  72457. url: string;
  72458. /**
  72459. * Defines the desired size (the more it increases the longer the generation will be)
  72460. */
  72461. size: number;
  72462. /**
  72463. * Defines if mipmaps should not be generated (default is false)
  72464. */
  72465. noMipmap: boolean;
  72466. /**
  72467. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72468. */
  72469. generateHarmonics: boolean;
  72470. /**
  72471. * 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)
  72472. */
  72473. gammaSpace: boolean;
  72474. /**
  72475. * Internal Use Only
  72476. */
  72477. reserved: boolean;
  72478. /**
  72479. * Gets the loaded texture
  72480. */
  72481. texture: HDRCubeTexture;
  72482. /**
  72483. * Callback called when the task is successful
  72484. */
  72485. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72486. /**
  72487. * Callback called when the task is successful
  72488. */
  72489. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72490. /**
  72491. * Creates a new HDRCubeTextureAssetTask object
  72492. * @param name defines the name of the task
  72493. * @param url defines the location of the file to load
  72494. * @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.
  72495. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72496. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72497. * @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)
  72498. * @param reserved Internal use only
  72499. */
  72500. constructor(
  72501. /**
  72502. * Defines the name of the task
  72503. */
  72504. name: string,
  72505. /**
  72506. * Defines the location of the file to load
  72507. */
  72508. url: string,
  72509. /**
  72510. * Defines the desired size (the more it increases the longer the generation will be)
  72511. */
  72512. size: number,
  72513. /**
  72514. * Defines if mipmaps should not be generated (default is false)
  72515. */
  72516. noMipmap?: boolean,
  72517. /**
  72518. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72519. */
  72520. generateHarmonics?: boolean,
  72521. /**
  72522. * 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)
  72523. */
  72524. gammaSpace?: boolean,
  72525. /**
  72526. * Internal Use Only
  72527. */
  72528. reserved?: boolean);
  72529. /**
  72530. * Execute the current task
  72531. * @param scene defines the scene where you want your assets to be loaded
  72532. * @param onSuccess is a callback called when the task is successfully executed
  72533. * @param onError is a callback called if an error occurs
  72534. */
  72535. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72536. }
  72537. /**
  72538. * Define a task used by AssetsManager to load Equirectangular cube textures
  72539. */
  72540. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72541. /**
  72542. * Defines the name of the task
  72543. */
  72544. name: string;
  72545. /**
  72546. * Defines the location of the file to load
  72547. */
  72548. url: string;
  72549. /**
  72550. * Defines the desired size (the more it increases the longer the generation will be)
  72551. */
  72552. size: number;
  72553. /**
  72554. * Defines if mipmaps should not be generated (default is false)
  72555. */
  72556. noMipmap: boolean;
  72557. /**
  72558. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72559. * but the standard material would require them in Gamma space) (default is true)
  72560. */
  72561. gammaSpace: boolean;
  72562. /**
  72563. * Gets the loaded texture
  72564. */
  72565. texture: EquiRectangularCubeTexture;
  72566. /**
  72567. * Callback called when the task is successful
  72568. */
  72569. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72570. /**
  72571. * Callback called when the task is successful
  72572. */
  72573. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72574. /**
  72575. * Creates a new EquiRectangularCubeTextureAssetTask object
  72576. * @param name defines the name of the task
  72577. * @param url defines the location of the file to load
  72578. * @param size defines the desired size (the more it increases the longer the generation will be)
  72579. * If the size is omitted this implies you are using a preprocessed cubemap.
  72580. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72581. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72582. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72583. * (default is true)
  72584. */
  72585. constructor(
  72586. /**
  72587. * Defines the name of the task
  72588. */
  72589. name: string,
  72590. /**
  72591. * Defines the location of the file to load
  72592. */
  72593. url: string,
  72594. /**
  72595. * Defines the desired size (the more it increases the longer the generation will be)
  72596. */
  72597. size: number,
  72598. /**
  72599. * Defines if mipmaps should not be generated (default is false)
  72600. */
  72601. noMipmap?: boolean,
  72602. /**
  72603. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72604. * but the standard material would require them in Gamma space) (default is true)
  72605. */
  72606. gammaSpace?: boolean);
  72607. /**
  72608. * Execute the current task
  72609. * @param scene defines the scene where you want your assets to be loaded
  72610. * @param onSuccess is a callback called when the task is successfully executed
  72611. * @param onError is a callback called if an error occurs
  72612. */
  72613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72614. }
  72615. /**
  72616. * This class can be used to easily import assets into a scene
  72617. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72618. */
  72619. export class AssetsManager {
  72620. private _scene;
  72621. private _isLoading;
  72622. protected _tasks: AbstractAssetTask[];
  72623. protected _waitingTasksCount: number;
  72624. protected _totalTasksCount: number;
  72625. /**
  72626. * Callback called when all tasks are processed
  72627. */
  72628. onFinish: (tasks: AbstractAssetTask[]) => void;
  72629. /**
  72630. * Callback called when a task is successful
  72631. */
  72632. onTaskSuccess: (task: AbstractAssetTask) => void;
  72633. /**
  72634. * Callback called when a task had an error
  72635. */
  72636. onTaskError: (task: AbstractAssetTask) => void;
  72637. /**
  72638. * Callback called when a task is done (whatever the result is)
  72639. */
  72640. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72641. /**
  72642. * Observable called when all tasks are processed
  72643. */
  72644. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72645. /**
  72646. * Observable called when a task had an error
  72647. */
  72648. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72649. /**
  72650. * Observable called when all tasks were executed
  72651. */
  72652. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72653. /**
  72654. * Observable called when a task is done (whatever the result is)
  72655. */
  72656. onProgressObservable: Observable<IAssetsProgressEvent>;
  72657. /**
  72658. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72659. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72660. */
  72661. useDefaultLoadingScreen: boolean;
  72662. /**
  72663. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72664. * when all assets have been downloaded.
  72665. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72666. */
  72667. autoHideLoadingUI: boolean;
  72668. /**
  72669. * Creates a new AssetsManager
  72670. * @param scene defines the scene to work on
  72671. */
  72672. constructor(scene: Scene);
  72673. /**
  72674. * Add a ContainerAssetTask to the list of active tasks
  72675. * @param taskName defines the name of the new task
  72676. * @param meshesNames defines the name of meshes to load
  72677. * @param rootUrl defines the root url to use to locate files
  72678. * @param sceneFilename defines the filename of the scene file
  72679. * @returns a new ContainerAssetTask object
  72680. */
  72681. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  72682. /**
  72683. * Add a MeshAssetTask to the list of active tasks
  72684. * @param taskName defines the name of the new task
  72685. * @param meshesNames defines the name of meshes to load
  72686. * @param rootUrl defines the root url to use to locate files
  72687. * @param sceneFilename defines the filename of the scene file
  72688. * @returns a new MeshAssetTask object
  72689. */
  72690. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72691. /**
  72692. * Add a TextFileAssetTask to the list of active tasks
  72693. * @param taskName defines the name of the new task
  72694. * @param url defines the url of the file to load
  72695. * @returns a new TextFileAssetTask object
  72696. */
  72697. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72698. /**
  72699. * Add a BinaryFileAssetTask to the list of active tasks
  72700. * @param taskName defines the name of the new task
  72701. * @param url defines the url of the file to load
  72702. * @returns a new BinaryFileAssetTask object
  72703. */
  72704. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72705. /**
  72706. * Add a ImageAssetTask to the list of active tasks
  72707. * @param taskName defines the name of the new task
  72708. * @param url defines the url of the file to load
  72709. * @returns a new ImageAssetTask object
  72710. */
  72711. addImageTask(taskName: string, url: string): ImageAssetTask;
  72712. /**
  72713. * Add a TextureAssetTask to the list of active tasks
  72714. * @param taskName defines the name of the new task
  72715. * @param url defines the url of the file to load
  72716. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72717. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72718. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72719. * @returns a new TextureAssetTask object
  72720. */
  72721. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72722. /**
  72723. * Add a CubeTextureAssetTask to the list of active tasks
  72724. * @param taskName defines the name of the new task
  72725. * @param url defines the url of the file to load
  72726. * @param extensions defines the extension to use to load the cube map (can be null)
  72727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72728. * @param files defines the list of files to load (can be null)
  72729. * @returns a new CubeTextureAssetTask object
  72730. */
  72731. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72732. /**
  72733. *
  72734. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72735. * @param taskName defines the name of the new task
  72736. * @param url defines the url of the file to load
  72737. * @param size defines the size you want for the cubemap (can be null)
  72738. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72739. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72740. * @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)
  72741. * @param reserved Internal use only
  72742. * @returns a new HDRCubeTextureAssetTask object
  72743. */
  72744. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72745. /**
  72746. *
  72747. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72748. * @param taskName defines the name of the new task
  72749. * @param url defines the url of the file to load
  72750. * @param size defines the size you want for the cubemap (can be null)
  72751. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72752. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72753. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72754. * @returns a new EquiRectangularCubeTextureAssetTask object
  72755. */
  72756. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72757. /**
  72758. * Remove a task from the assets manager.
  72759. * @param task the task to remove
  72760. */
  72761. removeTask(task: AbstractAssetTask): void;
  72762. private _decreaseWaitingTasksCount;
  72763. private _runTask;
  72764. /**
  72765. * Reset the AssetsManager and remove all tasks
  72766. * @return the current instance of the AssetsManager
  72767. */
  72768. reset(): AssetsManager;
  72769. /**
  72770. * Start the loading process
  72771. * @return the current instance of the AssetsManager
  72772. */
  72773. load(): AssetsManager;
  72774. /**
  72775. * Start the loading process as an async operation
  72776. * @return a promise returning the list of failed tasks
  72777. */
  72778. loadAsync(): Promise<void>;
  72779. }
  72780. }
  72781. declare module BABYLON {
  72782. /**
  72783. * Wrapper class for promise with external resolve and reject.
  72784. */
  72785. export class Deferred<T> {
  72786. /**
  72787. * The promise associated with this deferred object.
  72788. */
  72789. readonly promise: Promise<T>;
  72790. private _resolve;
  72791. private _reject;
  72792. /**
  72793. * The resolve method of the promise associated with this deferred object.
  72794. */
  72795. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72796. /**
  72797. * The reject method of the promise associated with this deferred object.
  72798. */
  72799. get reject(): (reason?: any) => void;
  72800. /**
  72801. * Constructor for this deferred object.
  72802. */
  72803. constructor();
  72804. }
  72805. }
  72806. declare module BABYLON {
  72807. /**
  72808. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72809. */
  72810. export class MeshExploder {
  72811. private _centerMesh;
  72812. private _meshes;
  72813. private _meshesOrigins;
  72814. private _toCenterVectors;
  72815. private _scaledDirection;
  72816. private _newPosition;
  72817. private _centerPosition;
  72818. /**
  72819. * Explodes meshes from a center mesh.
  72820. * @param meshes The meshes to explode.
  72821. * @param centerMesh The mesh to be center of explosion.
  72822. */
  72823. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72824. private _setCenterMesh;
  72825. /**
  72826. * Get class name
  72827. * @returns "MeshExploder"
  72828. */
  72829. getClassName(): string;
  72830. /**
  72831. * "Exploded meshes"
  72832. * @returns Array of meshes with the centerMesh at index 0.
  72833. */
  72834. getMeshes(): Array<Mesh>;
  72835. /**
  72836. * Explodes meshes giving a specific direction
  72837. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72838. */
  72839. explode(direction?: number): void;
  72840. }
  72841. }
  72842. declare module BABYLON {
  72843. /**
  72844. * Class used to help managing file picking and drag'n'drop
  72845. */
  72846. export class FilesInput {
  72847. /**
  72848. * List of files ready to be loaded
  72849. */
  72850. static get FilesToLoad(): {
  72851. [key: string]: File;
  72852. };
  72853. /**
  72854. * Callback called when a file is processed
  72855. */
  72856. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72857. private _engine;
  72858. private _currentScene;
  72859. private _sceneLoadedCallback;
  72860. private _progressCallback;
  72861. private _additionalRenderLoopLogicCallback;
  72862. private _textureLoadingCallback;
  72863. private _startingProcessingFilesCallback;
  72864. private _onReloadCallback;
  72865. private _errorCallback;
  72866. private _elementToMonitor;
  72867. private _sceneFileToLoad;
  72868. private _filesToLoad;
  72869. /**
  72870. * Creates a new FilesInput
  72871. * @param engine defines the rendering engine
  72872. * @param scene defines the hosting scene
  72873. * @param sceneLoadedCallback callback called when scene is loaded
  72874. * @param progressCallback callback called to track progress
  72875. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72876. * @param textureLoadingCallback callback called when a texture is loading
  72877. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72878. * @param onReloadCallback callback called when a reload is requested
  72879. * @param errorCallback callback call if an error occurs
  72880. */
  72881. 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>);
  72882. private _dragEnterHandler;
  72883. private _dragOverHandler;
  72884. private _dropHandler;
  72885. /**
  72886. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72887. * @param elementToMonitor defines the DOM element to track
  72888. */
  72889. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72890. /** Gets the current list of files to load */
  72891. get filesToLoad(): File[];
  72892. /**
  72893. * Release all associated resources
  72894. */
  72895. dispose(): void;
  72896. private renderFunction;
  72897. private drag;
  72898. private drop;
  72899. private _traverseFolder;
  72900. private _processFiles;
  72901. /**
  72902. * Load files from a drop event
  72903. * @param event defines the drop event to use as source
  72904. */
  72905. loadFiles(event: any): void;
  72906. private _processReload;
  72907. /**
  72908. * Reload the current scene from the loaded files
  72909. */
  72910. reload(): void;
  72911. }
  72912. }
  72913. declare module BABYLON {
  72914. /**
  72915. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72916. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72917. */
  72918. export class SceneOptimization {
  72919. /**
  72920. * Defines the priority of this optimization (0 by default which means first in the list)
  72921. */
  72922. priority: number;
  72923. /**
  72924. * Gets a string describing the action executed by the current optimization
  72925. * @returns description string
  72926. */
  72927. getDescription(): string;
  72928. /**
  72929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72930. * @param scene defines the current scene where to apply this optimization
  72931. * @param optimizer defines the current optimizer
  72932. * @returns true if everything that can be done was applied
  72933. */
  72934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72935. /**
  72936. * Creates the SceneOptimization object
  72937. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72938. * @param desc defines the description associated with the optimization
  72939. */
  72940. constructor(
  72941. /**
  72942. * Defines the priority of this optimization (0 by default which means first in the list)
  72943. */
  72944. priority?: number);
  72945. }
  72946. /**
  72947. * Defines an optimization used to reduce the size of render target textures
  72948. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72949. */
  72950. export class TextureOptimization extends SceneOptimization {
  72951. /**
  72952. * Defines the priority of this optimization (0 by default which means first in the list)
  72953. */
  72954. priority: number;
  72955. /**
  72956. * 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
  72957. */
  72958. maximumSize: number;
  72959. /**
  72960. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72961. */
  72962. step: number;
  72963. /**
  72964. * Gets a string describing the action executed by the current optimization
  72965. * @returns description string
  72966. */
  72967. getDescription(): string;
  72968. /**
  72969. * Creates the TextureOptimization object
  72970. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72971. * @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
  72972. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72973. */
  72974. constructor(
  72975. /**
  72976. * Defines the priority of this optimization (0 by default which means first in the list)
  72977. */
  72978. priority?: number,
  72979. /**
  72980. * 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
  72981. */
  72982. maximumSize?: number,
  72983. /**
  72984. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72985. */
  72986. step?: number);
  72987. /**
  72988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72989. * @param scene defines the current scene where to apply this optimization
  72990. * @param optimizer defines the current optimizer
  72991. * @returns true if everything that can be done was applied
  72992. */
  72993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72994. }
  72995. /**
  72996. * Defines an optimization used to increase or decrease the rendering resolution
  72997. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72998. */
  72999. export class HardwareScalingOptimization extends SceneOptimization {
  73000. /**
  73001. * Defines the priority of this optimization (0 by default which means first in the list)
  73002. */
  73003. priority: number;
  73004. /**
  73005. * Defines the maximum scale to use (2 by default)
  73006. */
  73007. maximumScale: number;
  73008. /**
  73009. * Defines the step to use between two passes (0.5 by default)
  73010. */
  73011. step: number;
  73012. private _currentScale;
  73013. private _directionOffset;
  73014. /**
  73015. * Gets a string describing the action executed by the current optimization
  73016. * @return description string
  73017. */
  73018. getDescription(): string;
  73019. /**
  73020. * Creates the HardwareScalingOptimization object
  73021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73022. * @param maximumScale defines the maximum scale to use (2 by default)
  73023. * @param step defines the step to use between two passes (0.5 by default)
  73024. */
  73025. constructor(
  73026. /**
  73027. * Defines the priority of this optimization (0 by default which means first in the list)
  73028. */
  73029. priority?: number,
  73030. /**
  73031. * Defines the maximum scale to use (2 by default)
  73032. */
  73033. maximumScale?: number,
  73034. /**
  73035. * Defines the step to use between two passes (0.5 by default)
  73036. */
  73037. step?: number);
  73038. /**
  73039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73040. * @param scene defines the current scene where to apply this optimization
  73041. * @param optimizer defines the current optimizer
  73042. * @returns true if everything that can be done was applied
  73043. */
  73044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73045. }
  73046. /**
  73047. * Defines an optimization used to remove shadows
  73048. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73049. */
  73050. export class ShadowsOptimization extends SceneOptimization {
  73051. /**
  73052. * Gets a string describing the action executed by the current optimization
  73053. * @return description string
  73054. */
  73055. getDescription(): string;
  73056. /**
  73057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73058. * @param scene defines the current scene where to apply this optimization
  73059. * @param optimizer defines the current optimizer
  73060. * @returns true if everything that can be done was applied
  73061. */
  73062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73063. }
  73064. /**
  73065. * Defines an optimization used to turn post-processes off
  73066. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73067. */
  73068. export class PostProcessesOptimization extends SceneOptimization {
  73069. /**
  73070. * Gets a string describing the action executed by the current optimization
  73071. * @return description string
  73072. */
  73073. getDescription(): string;
  73074. /**
  73075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73076. * @param scene defines the current scene where to apply this optimization
  73077. * @param optimizer defines the current optimizer
  73078. * @returns true if everything that can be done was applied
  73079. */
  73080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73081. }
  73082. /**
  73083. * Defines an optimization used to turn lens flares off
  73084. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73085. */
  73086. export class LensFlaresOptimization extends SceneOptimization {
  73087. /**
  73088. * Gets a string describing the action executed by the current optimization
  73089. * @return description string
  73090. */
  73091. getDescription(): string;
  73092. /**
  73093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73094. * @param scene defines the current scene where to apply this optimization
  73095. * @param optimizer defines the current optimizer
  73096. * @returns true if everything that can be done was applied
  73097. */
  73098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73099. }
  73100. /**
  73101. * Defines an optimization based on user defined callback.
  73102. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73103. */
  73104. export class CustomOptimization extends SceneOptimization {
  73105. /**
  73106. * Callback called to apply the custom optimization.
  73107. */
  73108. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73109. /**
  73110. * Callback called to get custom description
  73111. */
  73112. onGetDescription: () => string;
  73113. /**
  73114. * Gets a string describing the action executed by the current optimization
  73115. * @returns description string
  73116. */
  73117. getDescription(): string;
  73118. /**
  73119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73120. * @param scene defines the current scene where to apply this optimization
  73121. * @param optimizer defines the current optimizer
  73122. * @returns true if everything that can be done was applied
  73123. */
  73124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73125. }
  73126. /**
  73127. * Defines an optimization used to turn particles off
  73128. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73129. */
  73130. export class ParticlesOptimization extends SceneOptimization {
  73131. /**
  73132. * Gets a string describing the action executed by the current optimization
  73133. * @return description string
  73134. */
  73135. getDescription(): string;
  73136. /**
  73137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73138. * @param scene defines the current scene where to apply this optimization
  73139. * @param optimizer defines the current optimizer
  73140. * @returns true if everything that can be done was applied
  73141. */
  73142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73143. }
  73144. /**
  73145. * Defines an optimization used to turn render targets off
  73146. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73147. */
  73148. export class RenderTargetsOptimization extends SceneOptimization {
  73149. /**
  73150. * Gets a string describing the action executed by the current optimization
  73151. * @return description string
  73152. */
  73153. getDescription(): string;
  73154. /**
  73155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73156. * @param scene defines the current scene where to apply this optimization
  73157. * @param optimizer defines the current optimizer
  73158. * @returns true if everything that can be done was applied
  73159. */
  73160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73161. }
  73162. /**
  73163. * Defines an optimization used to merge meshes with compatible materials
  73164. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73165. */
  73166. export class MergeMeshesOptimization extends SceneOptimization {
  73167. private static _UpdateSelectionTree;
  73168. /**
  73169. * Gets or sets a boolean which defines if optimization octree has to be updated
  73170. */
  73171. static get UpdateSelectionTree(): boolean;
  73172. /**
  73173. * Gets or sets a boolean which defines if optimization octree has to be updated
  73174. */
  73175. static set UpdateSelectionTree(value: boolean);
  73176. /**
  73177. * Gets a string describing the action executed by the current optimization
  73178. * @return description string
  73179. */
  73180. getDescription(): string;
  73181. private _canBeMerged;
  73182. /**
  73183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73184. * @param scene defines the current scene where to apply this optimization
  73185. * @param optimizer defines the current optimizer
  73186. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73187. * @returns true if everything that can be done was applied
  73188. */
  73189. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73190. }
  73191. /**
  73192. * Defines a list of options used by SceneOptimizer
  73193. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73194. */
  73195. export class SceneOptimizerOptions {
  73196. /**
  73197. * Defines the target frame rate to reach (60 by default)
  73198. */
  73199. targetFrameRate: number;
  73200. /**
  73201. * Defines the interval between two checkes (2000ms by default)
  73202. */
  73203. trackerDuration: number;
  73204. /**
  73205. * Gets the list of optimizations to apply
  73206. */
  73207. optimizations: SceneOptimization[];
  73208. /**
  73209. * Creates a new list of options used by SceneOptimizer
  73210. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73211. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73212. */
  73213. constructor(
  73214. /**
  73215. * Defines the target frame rate to reach (60 by default)
  73216. */
  73217. targetFrameRate?: number,
  73218. /**
  73219. * Defines the interval between two checkes (2000ms by default)
  73220. */
  73221. trackerDuration?: number);
  73222. /**
  73223. * Add a new optimization
  73224. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73225. * @returns the current SceneOptimizerOptions
  73226. */
  73227. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73228. /**
  73229. * Add a new custom optimization
  73230. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73231. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73232. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73233. * @returns the current SceneOptimizerOptions
  73234. */
  73235. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73236. /**
  73237. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73238. * @param targetFrameRate defines the target frame rate (60 by default)
  73239. * @returns a SceneOptimizerOptions object
  73240. */
  73241. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73242. /**
  73243. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73244. * @param targetFrameRate defines the target frame rate (60 by default)
  73245. * @returns a SceneOptimizerOptions object
  73246. */
  73247. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73248. /**
  73249. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73250. * @param targetFrameRate defines the target frame rate (60 by default)
  73251. * @returns a SceneOptimizerOptions object
  73252. */
  73253. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73254. }
  73255. /**
  73256. * Class used to run optimizations in order to reach a target frame rate
  73257. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73258. */
  73259. export class SceneOptimizer implements IDisposable {
  73260. private _isRunning;
  73261. private _options;
  73262. private _scene;
  73263. private _currentPriorityLevel;
  73264. private _targetFrameRate;
  73265. private _trackerDuration;
  73266. private _currentFrameRate;
  73267. private _sceneDisposeObserver;
  73268. private _improvementMode;
  73269. /**
  73270. * Defines an observable called when the optimizer reaches the target frame rate
  73271. */
  73272. onSuccessObservable: Observable<SceneOptimizer>;
  73273. /**
  73274. * Defines an observable called when the optimizer enables an optimization
  73275. */
  73276. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73277. /**
  73278. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73279. */
  73280. onFailureObservable: Observable<SceneOptimizer>;
  73281. /**
  73282. * Gets a boolean indicating if the optimizer is in improvement mode
  73283. */
  73284. get isInImprovementMode(): boolean;
  73285. /**
  73286. * Gets the current priority level (0 at start)
  73287. */
  73288. get currentPriorityLevel(): number;
  73289. /**
  73290. * Gets the current frame rate checked by the SceneOptimizer
  73291. */
  73292. get currentFrameRate(): number;
  73293. /**
  73294. * Gets or sets the current target frame rate (60 by default)
  73295. */
  73296. get targetFrameRate(): number;
  73297. /**
  73298. * Gets or sets the current target frame rate (60 by default)
  73299. */
  73300. set targetFrameRate(value: number);
  73301. /**
  73302. * Gets or sets the current interval between two checks (every 2000ms by default)
  73303. */
  73304. get trackerDuration(): number;
  73305. /**
  73306. * Gets or sets the current interval between two checks (every 2000ms by default)
  73307. */
  73308. set trackerDuration(value: number);
  73309. /**
  73310. * Gets the list of active optimizations
  73311. */
  73312. get optimizations(): SceneOptimization[];
  73313. /**
  73314. * Creates a new SceneOptimizer
  73315. * @param scene defines the scene to work on
  73316. * @param options defines the options to use with the SceneOptimizer
  73317. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73318. * @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)
  73319. */
  73320. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73321. /**
  73322. * Stops the current optimizer
  73323. */
  73324. stop(): void;
  73325. /**
  73326. * Reset the optimizer to initial step (current priority level = 0)
  73327. */
  73328. reset(): void;
  73329. /**
  73330. * Start the optimizer. By default it will try to reach a specific framerate
  73331. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73332. */
  73333. start(): void;
  73334. private _checkCurrentState;
  73335. /**
  73336. * Release all resources
  73337. */
  73338. dispose(): void;
  73339. /**
  73340. * Helper function to create a SceneOptimizer with one single line of code
  73341. * @param scene defines the scene to work on
  73342. * @param options defines the options to use with the SceneOptimizer
  73343. * @param onSuccess defines a callback to call on success
  73344. * @param onFailure defines a callback to call on failure
  73345. * @returns the new SceneOptimizer object
  73346. */
  73347. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73348. }
  73349. }
  73350. declare module BABYLON {
  73351. /**
  73352. * Class used to serialize a scene into a string
  73353. */
  73354. export class SceneSerializer {
  73355. /**
  73356. * Clear cache used by a previous serialization
  73357. */
  73358. static ClearCache(): void;
  73359. /**
  73360. * Serialize a scene into a JSON compatible object
  73361. * @param scene defines the scene to serialize
  73362. * @returns a JSON compatible object
  73363. */
  73364. static Serialize(scene: Scene): any;
  73365. /**
  73366. * Serialize a mesh into a JSON compatible object
  73367. * @param toSerialize defines the mesh to serialize
  73368. * @param withParents defines if parents must be serialized as well
  73369. * @param withChildren defines if children must be serialized as well
  73370. * @returns a JSON compatible object
  73371. */
  73372. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73373. }
  73374. }
  73375. declare module BABYLON {
  73376. /**
  73377. * Class used to host texture specific utilities
  73378. */
  73379. export class TextureTools {
  73380. /**
  73381. * Uses the GPU to create a copy texture rescaled at a given size
  73382. * @param texture Texture to copy from
  73383. * @param width defines the desired width
  73384. * @param height defines the desired height
  73385. * @param useBilinearMode defines if bilinear mode has to be used
  73386. * @return the generated texture
  73387. */
  73388. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73389. }
  73390. }
  73391. declare module BABYLON {
  73392. /**
  73393. * This represents the different options available for the video capture.
  73394. */
  73395. export interface VideoRecorderOptions {
  73396. /** Defines the mime type of the video. */
  73397. mimeType: string;
  73398. /** Defines the FPS the video should be recorded at. */
  73399. fps: number;
  73400. /** Defines the chunk size for the recording data. */
  73401. recordChunckSize: number;
  73402. /** The audio tracks to attach to the recording. */
  73403. audioTracks?: MediaStreamTrack[];
  73404. }
  73405. /**
  73406. * This can help with recording videos from BabylonJS.
  73407. * This is based on the available WebRTC functionalities of the browser.
  73408. *
  73409. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73410. */
  73411. export class VideoRecorder {
  73412. private static readonly _defaultOptions;
  73413. /**
  73414. * Returns whether or not the VideoRecorder is available in your browser.
  73415. * @param engine Defines the Babylon Engine.
  73416. * @returns true if supported otherwise false.
  73417. */
  73418. static IsSupported(engine: Engine): boolean;
  73419. private readonly _options;
  73420. private _canvas;
  73421. private _mediaRecorder;
  73422. private _recordedChunks;
  73423. private _fileName;
  73424. private _resolve;
  73425. private _reject;
  73426. /**
  73427. * True when a recording is already in progress.
  73428. */
  73429. get isRecording(): boolean;
  73430. /**
  73431. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73432. * @param engine Defines the BabylonJS Engine you wish to record.
  73433. * @param options Defines options that can be used to customize the capture.
  73434. */
  73435. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73436. /**
  73437. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73438. */
  73439. stopRecording(): void;
  73440. /**
  73441. * Starts recording the canvas for a max duration specified in parameters.
  73442. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73443. * If null no automatic download will start and you can rely on the promise to get the data back.
  73444. * @param maxDuration Defines the maximum recording time in seconds.
  73445. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73446. * @return A promise callback at the end of the recording with the video data in Blob.
  73447. */
  73448. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73449. /**
  73450. * Releases internal resources used during the recording.
  73451. */
  73452. dispose(): void;
  73453. private _handleDataAvailable;
  73454. private _handleError;
  73455. private _handleStop;
  73456. }
  73457. }
  73458. declare module BABYLON {
  73459. /**
  73460. * Class containing a set of static utilities functions for screenshots
  73461. */
  73462. export class ScreenshotTools {
  73463. /**
  73464. * Captures a screenshot of the current rendering
  73465. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73466. * @param engine defines the rendering engine
  73467. * @param camera defines the source camera
  73468. * @param size This parameter can be set to a single number or to an object with the
  73469. * following (optional) properties: precision, width, height. If a single number is passed,
  73470. * it will be used for both width and height. If an object is passed, the screenshot size
  73471. * will be derived from the parameters. The precision property is a multiplier allowing
  73472. * rendering at a higher or lower resolution
  73473. * @param successCallback defines the callback receives a single parameter which contains the
  73474. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73475. * src parameter of an <img> to display it
  73476. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73477. * Check your browser for supported MIME types
  73478. */
  73479. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73480. /**
  73481. * Captures a screenshot of the current rendering
  73482. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73483. * @param engine defines the rendering engine
  73484. * @param camera defines the source camera
  73485. * @param size This parameter can be set to a single number or to an object with the
  73486. * following (optional) properties: precision, width, height. If a single number is passed,
  73487. * it will be used for both width and height. If an object is passed, the screenshot size
  73488. * will be derived from the parameters. The precision property is a multiplier allowing
  73489. * rendering at a higher or lower resolution
  73490. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73491. * Check your browser for supported MIME types
  73492. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73493. * to the src parameter of an <img> to display it
  73494. */
  73495. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73496. /**
  73497. * Generates an image screenshot from the specified camera.
  73498. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73499. * @param engine The engine to use for rendering
  73500. * @param camera The camera to use for rendering
  73501. * @param size This parameter can be set to a single number or to an object with the
  73502. * following (optional) properties: precision, width, height. If a single number is passed,
  73503. * it will be used for both width and height. If an object is passed, the screenshot size
  73504. * will be derived from the parameters. The precision property is a multiplier allowing
  73505. * rendering at a higher or lower resolution
  73506. * @param successCallback The callback receives a single parameter which contains the
  73507. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73508. * src parameter of an <img> to display it
  73509. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73510. * Check your browser for supported MIME types
  73511. * @param samples Texture samples (default: 1)
  73512. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73513. * @param fileName A name for for the downloaded file.
  73514. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73515. */
  73516. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73517. /**
  73518. * Generates an image screenshot from the specified camera.
  73519. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73520. * @param engine The engine to use for rendering
  73521. * @param camera The camera to use for rendering
  73522. * @param size This parameter can be set to a single number or to an object with the
  73523. * following (optional) properties: precision, width, height. If a single number is passed,
  73524. * it will be used for both width and height. If an object is passed, the screenshot size
  73525. * will be derived from the parameters. The precision property is a multiplier allowing
  73526. * rendering at a higher or lower resolution
  73527. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73528. * Check your browser for supported MIME types
  73529. * @param samples Texture samples (default: 1)
  73530. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73531. * @param fileName A name for for the downloaded file.
  73532. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73533. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73534. * to the src parameter of an <img> to display it
  73535. */
  73536. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73537. /**
  73538. * Gets height and width for screenshot size
  73539. * @private
  73540. */
  73541. private static _getScreenshotSize;
  73542. }
  73543. }
  73544. declare module BABYLON {
  73545. /**
  73546. * Interface for a data buffer
  73547. */
  73548. export interface IDataBuffer {
  73549. /**
  73550. * Reads bytes from the data buffer.
  73551. * @param byteOffset The byte offset to read
  73552. * @param byteLength The byte length to read
  73553. * @returns A promise that resolves when the bytes are read
  73554. */
  73555. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73556. /**
  73557. * The byte length of the buffer.
  73558. */
  73559. readonly byteLength: number;
  73560. }
  73561. /**
  73562. * Utility class for reading from a data buffer
  73563. */
  73564. export class DataReader {
  73565. /**
  73566. * The data buffer associated with this data reader.
  73567. */
  73568. readonly buffer: IDataBuffer;
  73569. /**
  73570. * The current byte offset from the beginning of the data buffer.
  73571. */
  73572. byteOffset: number;
  73573. private _dataView;
  73574. private _dataByteOffset;
  73575. /**
  73576. * Constructor
  73577. * @param buffer The buffer to read
  73578. */
  73579. constructor(buffer: IDataBuffer);
  73580. /**
  73581. * Loads the given byte length.
  73582. * @param byteLength The byte length to load
  73583. * @returns A promise that resolves when the load is complete
  73584. */
  73585. loadAsync(byteLength: number): Promise<void>;
  73586. /**
  73587. * Read a unsigned 32-bit integer from the currently loaded data range.
  73588. * @returns The 32-bit integer read
  73589. */
  73590. readUint32(): number;
  73591. /**
  73592. * Read a byte array from the currently loaded data range.
  73593. * @param byteLength The byte length to read
  73594. * @returns The byte array read
  73595. */
  73596. readUint8Array(byteLength: number): Uint8Array;
  73597. /**
  73598. * Read a string from the currently loaded data range.
  73599. * @param byteLength The byte length to read
  73600. * @returns The string read
  73601. */
  73602. readString(byteLength: number): string;
  73603. /**
  73604. * Skips the given byte length the currently loaded data range.
  73605. * @param byteLength The byte length to skip
  73606. */
  73607. skipBytes(byteLength: number): void;
  73608. }
  73609. }
  73610. declare module BABYLON {
  73611. /**
  73612. * Class for storing data to local storage if available or in-memory storage otherwise
  73613. */
  73614. export class DataStorage {
  73615. private static _Storage;
  73616. private static _GetStorage;
  73617. /**
  73618. * Reads a string from the data storage
  73619. * @param key The key to read
  73620. * @param defaultValue The value if the key doesn't exist
  73621. * @returns The string value
  73622. */
  73623. static ReadString(key: string, defaultValue: string): string;
  73624. /**
  73625. * Writes a string to the data storage
  73626. * @param key The key to write
  73627. * @param value The value to write
  73628. */
  73629. static WriteString(key: string, value: string): void;
  73630. /**
  73631. * Reads a boolean from the data storage
  73632. * @param key The key to read
  73633. * @param defaultValue The value if the key doesn't exist
  73634. * @returns The boolean value
  73635. */
  73636. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73637. /**
  73638. * Writes a boolean to the data storage
  73639. * @param key The key to write
  73640. * @param value The value to write
  73641. */
  73642. static WriteBoolean(key: string, value: boolean): void;
  73643. /**
  73644. * Reads a number from the data storage
  73645. * @param key The key to read
  73646. * @param defaultValue The value if the key doesn't exist
  73647. * @returns The number value
  73648. */
  73649. static ReadNumber(key: string, defaultValue: number): number;
  73650. /**
  73651. * Writes a number to the data storage
  73652. * @param key The key to write
  73653. * @param value The value to write
  73654. */
  73655. static WriteNumber(key: string, value: number): void;
  73656. }
  73657. }
  73658. declare module BABYLON {
  73659. /**
  73660. * Class used to record delta files between 2 scene states
  73661. */
  73662. export class SceneRecorder {
  73663. private _trackedScene;
  73664. private _savedJSON;
  73665. /**
  73666. * Track a given scene. This means the current scene state will be considered the original state
  73667. * @param scene defines the scene to track
  73668. */
  73669. track(scene: Scene): void;
  73670. /**
  73671. * Get the delta between current state and original state
  73672. * @returns a string containing the delta
  73673. */
  73674. getDelta(): any;
  73675. private _compareArray;
  73676. private _compareObjects;
  73677. private _compareCollections;
  73678. private static GetShadowGeneratorById;
  73679. /**
  73680. * Apply a given delta to a given scene
  73681. * @param deltaJSON defines the JSON containing the delta
  73682. * @param scene defines the scene to apply the delta to
  73683. */
  73684. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  73685. private static _ApplyPropertiesToEntity;
  73686. private static _ApplyDeltaForEntity;
  73687. }
  73688. }
  73689. declare module BABYLON {
  73690. /**
  73691. * An interface for all Hit test features
  73692. */
  73693. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73694. /**
  73695. * Triggered when new babylon (transformed) hit test results are available
  73696. */
  73697. onHitTestResultObservable: Observable<T[]>;
  73698. }
  73699. /**
  73700. * Options used for hit testing
  73701. */
  73702. export interface IWebXRLegacyHitTestOptions {
  73703. /**
  73704. * Only test when user interacted with the scene. Default - hit test every frame
  73705. */
  73706. testOnPointerDownOnly?: boolean;
  73707. /**
  73708. * The node to use to transform the local results to world coordinates
  73709. */
  73710. worldParentNode?: TransformNode;
  73711. }
  73712. /**
  73713. * Interface defining the babylon result of raycasting/hit-test
  73714. */
  73715. export interface IWebXRLegacyHitResult {
  73716. /**
  73717. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73718. */
  73719. transformationMatrix: Matrix;
  73720. /**
  73721. * The native hit test result
  73722. */
  73723. xrHitResult: XRHitResult | XRHitTestResult;
  73724. }
  73725. /**
  73726. * The currently-working hit-test module.
  73727. * Hit test (or Ray-casting) is used to interact with the real world.
  73728. * For further information read here - https://github.com/immersive-web/hit-test
  73729. */
  73730. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73731. /**
  73732. * options to use when constructing this feature
  73733. */
  73734. readonly options: IWebXRLegacyHitTestOptions;
  73735. private _direction;
  73736. private _mat;
  73737. private _onSelectEnabled;
  73738. private _origin;
  73739. /**
  73740. * The module's name
  73741. */
  73742. static readonly Name: string;
  73743. /**
  73744. * The (Babylon) version of this module.
  73745. * This is an integer representing the implementation version.
  73746. * This number does not correspond to the WebXR specs version
  73747. */
  73748. static readonly Version: number;
  73749. /**
  73750. * Populated with the last native XR Hit Results
  73751. */
  73752. lastNativeXRHitResults: XRHitResult[];
  73753. /**
  73754. * Triggered when new babylon (transformed) hit test results are available
  73755. */
  73756. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73757. /**
  73758. * Creates a new instance of the (legacy version) hit test feature
  73759. * @param _xrSessionManager an instance of WebXRSessionManager
  73760. * @param options options to use when constructing this feature
  73761. */
  73762. constructor(_xrSessionManager: WebXRSessionManager,
  73763. /**
  73764. * options to use when constructing this feature
  73765. */
  73766. options?: IWebXRLegacyHitTestOptions);
  73767. /**
  73768. * execute a hit test with an XR Ray
  73769. *
  73770. * @param xrSession a native xrSession that will execute this hit test
  73771. * @param xrRay the ray (position and direction) to use for ray-casting
  73772. * @param referenceSpace native XR reference space to use for the hit-test
  73773. * @param filter filter function that will filter the results
  73774. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73775. */
  73776. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73777. /**
  73778. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73779. * @param event the (select) event to use to select with
  73780. * @param referenceSpace the reference space to use for this hit test
  73781. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73782. */
  73783. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73784. /**
  73785. * attach this feature
  73786. * Will usually be called by the features manager
  73787. *
  73788. * @returns true if successful.
  73789. */
  73790. attach(): boolean;
  73791. /**
  73792. * detach this feature.
  73793. * Will usually be called by the features manager
  73794. *
  73795. * @returns true if successful.
  73796. */
  73797. detach(): boolean;
  73798. /**
  73799. * Dispose this feature and all of the resources attached
  73800. */
  73801. dispose(): void;
  73802. protected _onXRFrame(frame: XRFrame): void;
  73803. private _onHitTestResults;
  73804. private _onSelect;
  73805. }
  73806. }
  73807. declare module BABYLON {
  73808. /**
  73809. * Options used for hit testing (version 2)
  73810. */
  73811. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73812. /**
  73813. * Do not create a permanent hit test. Will usually be used when only
  73814. * transient inputs are needed.
  73815. */
  73816. disablePermanentHitTest?: boolean;
  73817. /**
  73818. * Enable transient (for example touch-based) hit test inspections
  73819. */
  73820. enableTransientHitTest?: boolean;
  73821. /**
  73822. * Offset ray for the permanent hit test
  73823. */
  73824. offsetRay?: Vector3;
  73825. /**
  73826. * Offset ray for the transient hit test
  73827. */
  73828. transientOffsetRay?: Vector3;
  73829. /**
  73830. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73831. */
  73832. useReferenceSpace?: boolean;
  73833. }
  73834. /**
  73835. * Interface defining the babylon result of hit-test
  73836. */
  73837. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73838. /**
  73839. * The input source that generated this hit test (if transient)
  73840. */
  73841. inputSource?: XRInputSource;
  73842. /**
  73843. * Is this a transient hit test
  73844. */
  73845. isTransient?: boolean;
  73846. /**
  73847. * Position of the hit test result
  73848. */
  73849. position: Vector3;
  73850. /**
  73851. * Rotation of the hit test result
  73852. */
  73853. rotationQuaternion: Quaternion;
  73854. /**
  73855. * The native hit test result
  73856. */
  73857. xrHitResult: XRHitTestResult;
  73858. }
  73859. /**
  73860. * The currently-working hit-test module.
  73861. * Hit test (or Ray-casting) is used to interact with the real world.
  73862. * For further information read here - https://github.com/immersive-web/hit-test
  73863. *
  73864. * Tested on chrome (mobile) 80.
  73865. */
  73866. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73867. /**
  73868. * options to use when constructing this feature
  73869. */
  73870. readonly options: IWebXRHitTestOptions;
  73871. private _tmpMat;
  73872. private _tmpPos;
  73873. private _tmpQuat;
  73874. private _transientXrHitTestSource;
  73875. private _xrHitTestSource;
  73876. private initHitTestSource;
  73877. /**
  73878. * The module's name
  73879. */
  73880. static readonly Name: string;
  73881. /**
  73882. * The (Babylon) version of this module.
  73883. * This is an integer representing the implementation version.
  73884. * This number does not correspond to the WebXR specs version
  73885. */
  73886. static readonly Version: number;
  73887. /**
  73888. * When set to true, each hit test will have its own position/rotation objects
  73889. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73890. * the developers will clone them or copy them as they see fit.
  73891. */
  73892. autoCloneTransformation: boolean;
  73893. /**
  73894. * Triggered when new babylon (transformed) hit test results are available
  73895. */
  73896. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73897. /**
  73898. * Use this to temporarily pause hit test checks.
  73899. */
  73900. paused: boolean;
  73901. /**
  73902. * Creates a new instance of the hit test feature
  73903. * @param _xrSessionManager an instance of WebXRSessionManager
  73904. * @param options options to use when constructing this feature
  73905. */
  73906. constructor(_xrSessionManager: WebXRSessionManager,
  73907. /**
  73908. * options to use when constructing this feature
  73909. */
  73910. options?: IWebXRHitTestOptions);
  73911. /**
  73912. * attach this feature
  73913. * Will usually be called by the features manager
  73914. *
  73915. * @returns true if successful.
  73916. */
  73917. attach(): boolean;
  73918. /**
  73919. * detach this feature.
  73920. * Will usually be called by the features manager
  73921. *
  73922. * @returns true if successful.
  73923. */
  73924. detach(): boolean;
  73925. /**
  73926. * Dispose this feature and all of the resources attached
  73927. */
  73928. dispose(): void;
  73929. protected _onXRFrame(frame: XRFrame): void;
  73930. private _processWebXRHitTestResult;
  73931. }
  73932. }
  73933. declare module BABYLON {
  73934. /**
  73935. * Configuration options of the anchor system
  73936. */
  73937. export interface IWebXRAnchorSystemOptions {
  73938. /**
  73939. * a node that will be used to convert local to world coordinates
  73940. */
  73941. worldParentNode?: TransformNode;
  73942. /**
  73943. * If set to true a reference of the created anchors will be kept until the next session starts
  73944. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73945. */
  73946. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73947. }
  73948. /**
  73949. * A babylon container for an XR Anchor
  73950. */
  73951. export interface IWebXRAnchor {
  73952. /**
  73953. * A babylon-assigned ID for this anchor
  73954. */
  73955. id: number;
  73956. /**
  73957. * Transformation matrix to apply to an object attached to this anchor
  73958. */
  73959. transformationMatrix: Matrix;
  73960. /**
  73961. * The native anchor object
  73962. */
  73963. xrAnchor: XRAnchor;
  73964. /**
  73965. * if defined, this object will be constantly updated by the anchor's position and rotation
  73966. */
  73967. attachedNode?: TransformNode;
  73968. }
  73969. /**
  73970. * An implementation of the anchor system for WebXR.
  73971. * For further information see https://github.com/immersive-web/anchors/
  73972. */
  73973. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73974. private _options;
  73975. private _lastFrameDetected;
  73976. private _trackedAnchors;
  73977. private _referenceSpaceForFrameAnchors;
  73978. private _futureAnchors;
  73979. /**
  73980. * The module's name
  73981. */
  73982. static readonly Name: string;
  73983. /**
  73984. * The (Babylon) version of this module.
  73985. * This is an integer representing the implementation version.
  73986. * This number does not correspond to the WebXR specs version
  73987. */
  73988. static readonly Version: number;
  73989. /**
  73990. * Observers registered here will be executed when a new anchor was added to the session
  73991. */
  73992. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73993. /**
  73994. * Observers registered here will be executed when an anchor was removed from the session
  73995. */
  73996. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73997. /**
  73998. * Observers registered here will be executed when an existing anchor updates
  73999. * This can execute N times every frame
  74000. */
  74001. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74002. /**
  74003. * Set the reference space to use for anchor creation, when not using a hit test.
  74004. * Will default to the session's reference space if not defined
  74005. */
  74006. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74007. /**
  74008. * constructs a new anchor system
  74009. * @param _xrSessionManager an instance of WebXRSessionManager
  74010. * @param _options configuration object for this feature
  74011. */
  74012. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74013. private _tmpVector;
  74014. private _tmpQuaternion;
  74015. private _populateTmpTransformation;
  74016. /**
  74017. * Create a new anchor point using a hit test result at a specific point in the scene
  74018. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74019. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74020. *
  74021. * @param hitTestResult The hit test result to use for this anchor creation
  74022. * @param position an optional position offset for this anchor
  74023. * @param rotationQuaternion an optional rotation offset for this anchor
  74024. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74025. */
  74026. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74027. /**
  74028. * Add a new anchor at a specific position and rotation
  74029. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74030. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74031. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74032. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74033. *
  74034. * @param position the position in which to add an anchor
  74035. * @param rotationQuaternion an optional rotation for the anchor transformation
  74036. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74037. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74038. */
  74039. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74040. /**
  74041. * detach this feature.
  74042. * Will usually be called by the features manager
  74043. *
  74044. * @returns true if successful.
  74045. */
  74046. detach(): boolean;
  74047. /**
  74048. * Dispose this feature and all of the resources attached
  74049. */
  74050. dispose(): void;
  74051. protected _onXRFrame(frame: XRFrame): void;
  74052. /**
  74053. * avoiding using Array.find for global support.
  74054. * @param xrAnchor the plane to find in the array
  74055. */
  74056. private _findIndexInAnchorArray;
  74057. private _updateAnchorWithXRFrame;
  74058. private _createAnchorAtTransformation;
  74059. }
  74060. }
  74061. declare module BABYLON {
  74062. /**
  74063. * Options used in the plane detector module
  74064. */
  74065. export interface IWebXRPlaneDetectorOptions {
  74066. /**
  74067. * The node to use to transform the local results to world coordinates
  74068. */
  74069. worldParentNode?: TransformNode;
  74070. /**
  74071. * If set to true a reference of the created planes will be kept until the next session starts
  74072. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74073. */
  74074. doNotRemovePlanesOnSessionEnded?: boolean;
  74075. }
  74076. /**
  74077. * A babylon interface for a WebXR plane.
  74078. * A Plane is actually a polygon, built from N points in space
  74079. *
  74080. * Supported in chrome 79, not supported in canary 81 ATM
  74081. */
  74082. export interface IWebXRPlane {
  74083. /**
  74084. * a babylon-assigned ID for this polygon
  74085. */
  74086. id: number;
  74087. /**
  74088. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74089. */
  74090. polygonDefinition: Array<Vector3>;
  74091. /**
  74092. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74093. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74094. */
  74095. transformationMatrix: Matrix;
  74096. /**
  74097. * the native xr-plane object
  74098. */
  74099. xrPlane: XRPlane;
  74100. }
  74101. /**
  74102. * The plane detector is used to detect planes in the real world when in AR
  74103. * For more information see https://github.com/immersive-web/real-world-geometry/
  74104. */
  74105. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74106. private _options;
  74107. private _detectedPlanes;
  74108. private _enabled;
  74109. private _lastFrameDetected;
  74110. /**
  74111. * The module's name
  74112. */
  74113. static readonly Name: string;
  74114. /**
  74115. * The (Babylon) version of this module.
  74116. * This is an integer representing the implementation version.
  74117. * This number does not correspond to the WebXR specs version
  74118. */
  74119. static readonly Version: number;
  74120. /**
  74121. * Observers registered here will be executed when a new plane was added to the session
  74122. */
  74123. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74124. /**
  74125. * Observers registered here will be executed when a plane is no longer detected in the session
  74126. */
  74127. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74128. /**
  74129. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74130. * This can execute N times every frame
  74131. */
  74132. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74133. /**
  74134. * construct a new Plane Detector
  74135. * @param _xrSessionManager an instance of xr Session manager
  74136. * @param _options configuration to use when constructing this feature
  74137. */
  74138. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74139. /**
  74140. * detach this feature.
  74141. * Will usually be called by the features manager
  74142. *
  74143. * @returns true if successful.
  74144. */
  74145. detach(): boolean;
  74146. /**
  74147. * Dispose this feature and all of the resources attached
  74148. */
  74149. dispose(): void;
  74150. protected _onXRFrame(frame: XRFrame): void;
  74151. private _init;
  74152. private _updatePlaneWithXRPlane;
  74153. /**
  74154. * avoiding using Array.find for global support.
  74155. * @param xrPlane the plane to find in the array
  74156. */
  74157. private findIndexInPlaneArray;
  74158. }
  74159. }
  74160. declare module BABYLON {
  74161. /**
  74162. * Options interface for the background remover plugin
  74163. */
  74164. export interface IWebXRBackgroundRemoverOptions {
  74165. /**
  74166. * Further background meshes to disable when entering AR
  74167. */
  74168. backgroundMeshes?: AbstractMesh[];
  74169. /**
  74170. * flags to configure the removal of the environment helper.
  74171. * If not set, the entire background will be removed. If set, flags should be set as well.
  74172. */
  74173. environmentHelperRemovalFlags?: {
  74174. /**
  74175. * Should the skybox be removed (default false)
  74176. */
  74177. skyBox?: boolean;
  74178. /**
  74179. * Should the ground be removed (default false)
  74180. */
  74181. ground?: boolean;
  74182. };
  74183. /**
  74184. * don't disable the environment helper
  74185. */
  74186. ignoreEnvironmentHelper?: boolean;
  74187. }
  74188. /**
  74189. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74190. */
  74191. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74192. /**
  74193. * read-only options to be used in this module
  74194. */
  74195. readonly options: IWebXRBackgroundRemoverOptions;
  74196. /**
  74197. * The module's name
  74198. */
  74199. static readonly Name: string;
  74200. /**
  74201. * The (Babylon) version of this module.
  74202. * This is an integer representing the implementation version.
  74203. * This number does not correspond to the WebXR specs version
  74204. */
  74205. static readonly Version: number;
  74206. /**
  74207. * registered observers will be triggered when the background state changes
  74208. */
  74209. onBackgroundStateChangedObservable: Observable<boolean>;
  74210. /**
  74211. * constructs a new background remover module
  74212. * @param _xrSessionManager the session manager for this module
  74213. * @param options read-only options to be used in this module
  74214. */
  74215. constructor(_xrSessionManager: WebXRSessionManager,
  74216. /**
  74217. * read-only options to be used in this module
  74218. */
  74219. options?: IWebXRBackgroundRemoverOptions);
  74220. /**
  74221. * attach this feature
  74222. * Will usually be called by the features manager
  74223. *
  74224. * @returns true if successful.
  74225. */
  74226. attach(): boolean;
  74227. /**
  74228. * detach this feature.
  74229. * Will usually be called by the features manager
  74230. *
  74231. * @returns true if successful.
  74232. */
  74233. detach(): boolean;
  74234. /**
  74235. * Dispose this feature and all of the resources attached
  74236. */
  74237. dispose(): void;
  74238. protected _onXRFrame(_xrFrame: XRFrame): void;
  74239. private _setBackgroundState;
  74240. }
  74241. }
  74242. declare module BABYLON {
  74243. /**
  74244. * Options for the controller physics feature
  74245. */
  74246. export class IWebXRControllerPhysicsOptions {
  74247. /**
  74248. * Should the headset get its own impostor
  74249. */
  74250. enableHeadsetImpostor?: boolean;
  74251. /**
  74252. * Optional parameters for the headset impostor
  74253. */
  74254. headsetImpostorParams?: {
  74255. /**
  74256. * The type of impostor to create. Default is sphere
  74257. */
  74258. impostorType: number;
  74259. /**
  74260. * the size of the impostor. Defaults to 10cm
  74261. */
  74262. impostorSize?: number | {
  74263. width: number;
  74264. height: number;
  74265. depth: number;
  74266. };
  74267. /**
  74268. * Friction definitions
  74269. */
  74270. friction?: number;
  74271. /**
  74272. * Restitution
  74273. */
  74274. restitution?: number;
  74275. };
  74276. /**
  74277. * The physics properties of the future impostors
  74278. */
  74279. physicsProperties?: {
  74280. /**
  74281. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74282. * Note that this requires a physics engine that supports mesh impostors!
  74283. */
  74284. useControllerMesh?: boolean;
  74285. /**
  74286. * The type of impostor to create. Default is sphere
  74287. */
  74288. impostorType?: number;
  74289. /**
  74290. * the size of the impostor. Defaults to 10cm
  74291. */
  74292. impostorSize?: number | {
  74293. width: number;
  74294. height: number;
  74295. depth: number;
  74296. };
  74297. /**
  74298. * Friction definitions
  74299. */
  74300. friction?: number;
  74301. /**
  74302. * Restitution
  74303. */
  74304. restitution?: number;
  74305. };
  74306. /**
  74307. * the xr input to use with this pointer selection
  74308. */
  74309. xrInput: WebXRInput;
  74310. }
  74311. /**
  74312. * Add physics impostor to your webxr controllers,
  74313. * including naive calculation of their linear and angular velocity
  74314. */
  74315. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74316. private readonly _options;
  74317. private _attachController;
  74318. private _controllers;
  74319. private _debugMode;
  74320. private _delta;
  74321. private _headsetImpostor?;
  74322. private _headsetMesh?;
  74323. private _lastTimestamp;
  74324. private _tmpQuaternion;
  74325. private _tmpVector;
  74326. /**
  74327. * The module's name
  74328. */
  74329. static readonly Name: string;
  74330. /**
  74331. * The (Babylon) version of this module.
  74332. * This is an integer representing the implementation version.
  74333. * This number does not correspond to the webxr specs version
  74334. */
  74335. static readonly Version: number;
  74336. /**
  74337. * Construct a new Controller Physics Feature
  74338. * @param _xrSessionManager the corresponding xr session manager
  74339. * @param _options options to create this feature with
  74340. */
  74341. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74342. /**
  74343. * @hidden
  74344. * enable debugging - will show console outputs and the impostor mesh
  74345. */
  74346. _enablePhysicsDebug(): void;
  74347. /**
  74348. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74349. * @param xrController the controller to add
  74350. */
  74351. addController(xrController: WebXRInputSource): void;
  74352. /**
  74353. * attach this feature
  74354. * Will usually be called by the features manager
  74355. *
  74356. * @returns true if successful.
  74357. */
  74358. attach(): boolean;
  74359. /**
  74360. * detach this feature.
  74361. * Will usually be called by the features manager
  74362. *
  74363. * @returns true if successful.
  74364. */
  74365. detach(): boolean;
  74366. /**
  74367. * Get the headset impostor, if enabled
  74368. * @returns the impostor
  74369. */
  74370. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74371. /**
  74372. * Get the physics impostor of a specific controller.
  74373. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74374. * @param controller the controller or the controller id of which to get the impostor
  74375. * @returns the impostor or null
  74376. */
  74377. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74378. /**
  74379. * Update the physics properties provided in the constructor
  74380. * @param newProperties the new properties object
  74381. */
  74382. setPhysicsProperties(newProperties: {
  74383. impostorType?: number;
  74384. impostorSize?: number | {
  74385. width: number;
  74386. height: number;
  74387. depth: number;
  74388. };
  74389. friction?: number;
  74390. restitution?: number;
  74391. }): void;
  74392. protected _onXRFrame(_xrFrame: any): void;
  74393. private _detachController;
  74394. }
  74395. }
  74396. declare module BABYLON {
  74397. /**
  74398. * The motion controller class for all microsoft mixed reality controllers
  74399. */
  74400. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74401. protected readonly _mapping: {
  74402. defaultButton: {
  74403. valueNodeName: string;
  74404. unpressedNodeName: string;
  74405. pressedNodeName: string;
  74406. };
  74407. defaultAxis: {
  74408. valueNodeName: string;
  74409. minNodeName: string;
  74410. maxNodeName: string;
  74411. };
  74412. buttons: {
  74413. "xr-standard-trigger": {
  74414. rootNodeName: string;
  74415. componentProperty: string;
  74416. states: string[];
  74417. };
  74418. "xr-standard-squeeze": {
  74419. rootNodeName: string;
  74420. componentProperty: string;
  74421. states: string[];
  74422. };
  74423. "xr-standard-touchpad": {
  74424. rootNodeName: string;
  74425. labelAnchorNodeName: string;
  74426. touchPointNodeName: string;
  74427. };
  74428. "xr-standard-thumbstick": {
  74429. rootNodeName: string;
  74430. componentProperty: string;
  74431. states: string[];
  74432. };
  74433. };
  74434. axes: {
  74435. "xr-standard-touchpad": {
  74436. "x-axis": {
  74437. rootNodeName: string;
  74438. };
  74439. "y-axis": {
  74440. rootNodeName: string;
  74441. };
  74442. };
  74443. "xr-standard-thumbstick": {
  74444. "x-axis": {
  74445. rootNodeName: string;
  74446. };
  74447. "y-axis": {
  74448. rootNodeName: string;
  74449. };
  74450. };
  74451. };
  74452. };
  74453. /**
  74454. * The base url used to load the left and right controller models
  74455. */
  74456. static MODEL_BASE_URL: string;
  74457. /**
  74458. * The name of the left controller model file
  74459. */
  74460. static MODEL_LEFT_FILENAME: string;
  74461. /**
  74462. * The name of the right controller model file
  74463. */
  74464. static MODEL_RIGHT_FILENAME: string;
  74465. profileId: string;
  74466. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74467. protected _getFilenameAndPath(): {
  74468. filename: string;
  74469. path: string;
  74470. };
  74471. protected _getModelLoadingConstraints(): boolean;
  74472. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74473. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74474. protected _updateModel(): void;
  74475. }
  74476. }
  74477. declare module BABYLON {
  74478. /**
  74479. * The motion controller class for oculus touch (quest, rift).
  74480. * This class supports legacy mapping as well the standard xr mapping
  74481. */
  74482. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74483. private _forceLegacyControllers;
  74484. private _modelRootNode;
  74485. /**
  74486. * The base url used to load the left and right controller models
  74487. */
  74488. static MODEL_BASE_URL: string;
  74489. /**
  74490. * The name of the left controller model file
  74491. */
  74492. static MODEL_LEFT_FILENAME: string;
  74493. /**
  74494. * The name of the right controller model file
  74495. */
  74496. static MODEL_RIGHT_FILENAME: string;
  74497. /**
  74498. * Base Url for the Quest controller model.
  74499. */
  74500. static QUEST_MODEL_BASE_URL: string;
  74501. profileId: string;
  74502. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74503. protected _getFilenameAndPath(): {
  74504. filename: string;
  74505. path: string;
  74506. };
  74507. protected _getModelLoadingConstraints(): boolean;
  74508. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74509. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74510. protected _updateModel(): void;
  74511. /**
  74512. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74513. * between the touch and touch 2.
  74514. */
  74515. private _isQuest;
  74516. }
  74517. }
  74518. declare module BABYLON {
  74519. /**
  74520. * The motion controller class for the standard HTC-Vive controllers
  74521. */
  74522. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74523. private _modelRootNode;
  74524. /**
  74525. * The base url used to load the left and right controller models
  74526. */
  74527. static MODEL_BASE_URL: string;
  74528. /**
  74529. * File name for the controller model.
  74530. */
  74531. static MODEL_FILENAME: string;
  74532. profileId: string;
  74533. /**
  74534. * Create a new Vive motion controller object
  74535. * @param scene the scene to use to create this controller
  74536. * @param gamepadObject the corresponding gamepad object
  74537. * @param handedness the handedness of the controller
  74538. */
  74539. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74540. protected _getFilenameAndPath(): {
  74541. filename: string;
  74542. path: string;
  74543. };
  74544. protected _getModelLoadingConstraints(): boolean;
  74545. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74546. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74547. protected _updateModel(): void;
  74548. }
  74549. }
  74550. declare module BABYLON {
  74551. /**
  74552. * A cursor which tracks a point on a path
  74553. */
  74554. export class PathCursor {
  74555. private path;
  74556. /**
  74557. * Stores path cursor callbacks for when an onchange event is triggered
  74558. */
  74559. private _onchange;
  74560. /**
  74561. * The value of the path cursor
  74562. */
  74563. value: number;
  74564. /**
  74565. * The animation array of the path cursor
  74566. */
  74567. animations: Animation[];
  74568. /**
  74569. * Initializes the path cursor
  74570. * @param path The path to track
  74571. */
  74572. constructor(path: Path2);
  74573. /**
  74574. * Gets the cursor point on the path
  74575. * @returns A point on the path cursor at the cursor location
  74576. */
  74577. getPoint(): Vector3;
  74578. /**
  74579. * Moves the cursor ahead by the step amount
  74580. * @param step The amount to move the cursor forward
  74581. * @returns This path cursor
  74582. */
  74583. moveAhead(step?: number): PathCursor;
  74584. /**
  74585. * Moves the cursor behind by the step amount
  74586. * @param step The amount to move the cursor back
  74587. * @returns This path cursor
  74588. */
  74589. moveBack(step?: number): PathCursor;
  74590. /**
  74591. * Moves the cursor by the step amount
  74592. * If the step amount is greater than one, an exception is thrown
  74593. * @param step The amount to move the cursor
  74594. * @returns This path cursor
  74595. */
  74596. move(step: number): PathCursor;
  74597. /**
  74598. * Ensures that the value is limited between zero and one
  74599. * @returns This path cursor
  74600. */
  74601. private ensureLimits;
  74602. /**
  74603. * Runs onchange callbacks on change (used by the animation engine)
  74604. * @returns This path cursor
  74605. */
  74606. private raiseOnChange;
  74607. /**
  74608. * Executes a function on change
  74609. * @param f A path cursor onchange callback
  74610. * @returns This path cursor
  74611. */
  74612. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74613. }
  74614. }
  74615. declare module BABYLON {
  74616. /** @hidden */
  74617. export var blurPixelShader: {
  74618. name: string;
  74619. shader: string;
  74620. };
  74621. }
  74622. declare module BABYLON {
  74623. /** @hidden */
  74624. export var pointCloudVertexDeclaration: {
  74625. name: string;
  74626. shader: string;
  74627. };
  74628. }
  74629. // Mixins
  74630. interface Window {
  74631. mozIndexedDB: IDBFactory;
  74632. webkitIndexedDB: IDBFactory;
  74633. msIndexedDB: IDBFactory;
  74634. webkitURL: typeof URL;
  74635. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74636. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74637. WebGLRenderingContext: WebGLRenderingContext;
  74638. MSGesture: MSGesture;
  74639. CANNON: any;
  74640. AudioContext: AudioContext;
  74641. webkitAudioContext: AudioContext;
  74642. PointerEvent: any;
  74643. Math: Math;
  74644. Uint8Array: Uint8ArrayConstructor;
  74645. Float32Array: Float32ArrayConstructor;
  74646. mozURL: typeof URL;
  74647. msURL: typeof URL;
  74648. VRFrameData: any; // WebVR, from specs 1.1
  74649. DracoDecoderModule: any;
  74650. setImmediate(handler: (...args: any[]) => void): number;
  74651. }
  74652. interface HTMLCanvasElement {
  74653. requestPointerLock(): void;
  74654. msRequestPointerLock?(): void;
  74655. mozRequestPointerLock?(): void;
  74656. webkitRequestPointerLock?(): void;
  74657. /** Track wether a record is in progress */
  74658. isRecording: boolean;
  74659. /** Capture Stream method defined by some browsers */
  74660. captureStream(fps?: number): MediaStream;
  74661. }
  74662. interface CanvasRenderingContext2D {
  74663. msImageSmoothingEnabled: boolean;
  74664. }
  74665. interface MouseEvent {
  74666. mozMovementX: number;
  74667. mozMovementY: number;
  74668. webkitMovementX: number;
  74669. webkitMovementY: number;
  74670. msMovementX: number;
  74671. msMovementY: number;
  74672. }
  74673. interface Navigator {
  74674. mozGetVRDevices: (any: any) => any;
  74675. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74676. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74677. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74678. webkitGetGamepads(): Gamepad[];
  74679. msGetGamepads(): Gamepad[];
  74680. webkitGamepads(): Gamepad[];
  74681. }
  74682. interface HTMLVideoElement {
  74683. mozSrcObject: any;
  74684. }
  74685. interface Math {
  74686. fround(x: number): number;
  74687. imul(a: number, b: number): number;
  74688. }
  74689. interface WebGLRenderingContext {
  74690. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74691. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74692. vertexAttribDivisor(index: number, divisor: number): void;
  74693. createVertexArray(): any;
  74694. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74695. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74696. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74697. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74698. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74699. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74700. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74701. // Queries
  74702. createQuery(): WebGLQuery;
  74703. deleteQuery(query: WebGLQuery): void;
  74704. beginQuery(target: number, query: WebGLQuery): void;
  74705. endQuery(target: number): void;
  74706. getQueryParameter(query: WebGLQuery, pname: number): any;
  74707. getQuery(target: number, pname: number): any;
  74708. MAX_SAMPLES: number;
  74709. RGBA8: number;
  74710. READ_FRAMEBUFFER: number;
  74711. DRAW_FRAMEBUFFER: number;
  74712. UNIFORM_BUFFER: number;
  74713. HALF_FLOAT_OES: number;
  74714. RGBA16F: number;
  74715. RGBA32F: number;
  74716. R32F: number;
  74717. RG32F: number;
  74718. RGB32F: number;
  74719. R16F: number;
  74720. RG16F: number;
  74721. RGB16F: number;
  74722. RED: number;
  74723. RG: number;
  74724. R8: number;
  74725. RG8: number;
  74726. UNSIGNED_INT_24_8: number;
  74727. DEPTH24_STENCIL8: number;
  74728. MIN: number;
  74729. MAX: number;
  74730. /* Multiple Render Targets */
  74731. drawBuffers(buffers: number[]): void;
  74732. readBuffer(src: number): void;
  74733. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74734. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74735. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74736. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74737. // Occlusion Query
  74738. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74739. ANY_SAMPLES_PASSED: number;
  74740. QUERY_RESULT_AVAILABLE: number;
  74741. QUERY_RESULT: number;
  74742. }
  74743. interface WebGLProgram {
  74744. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74745. }
  74746. interface EXT_disjoint_timer_query {
  74747. QUERY_COUNTER_BITS_EXT: number;
  74748. TIME_ELAPSED_EXT: number;
  74749. TIMESTAMP_EXT: number;
  74750. GPU_DISJOINT_EXT: number;
  74751. QUERY_RESULT_EXT: number;
  74752. QUERY_RESULT_AVAILABLE_EXT: number;
  74753. queryCounterEXT(query: WebGLQuery, target: number): void;
  74754. createQueryEXT(): WebGLQuery;
  74755. beginQueryEXT(target: number, query: WebGLQuery): void;
  74756. endQueryEXT(target: number): void;
  74757. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74758. deleteQueryEXT(query: WebGLQuery): void;
  74759. }
  74760. interface WebGLUniformLocation {
  74761. _currentState: any;
  74762. }
  74763. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74764. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74765. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74766. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74767. interface WebGLRenderingContext {
  74768. readonly RASTERIZER_DISCARD: number;
  74769. readonly DEPTH_COMPONENT24: number;
  74770. readonly TEXTURE_3D: number;
  74771. readonly TEXTURE_2D_ARRAY: number;
  74772. readonly TEXTURE_COMPARE_FUNC: number;
  74773. readonly TEXTURE_COMPARE_MODE: number;
  74774. readonly COMPARE_REF_TO_TEXTURE: number;
  74775. readonly TEXTURE_WRAP_R: number;
  74776. readonly HALF_FLOAT: number;
  74777. readonly RGB8: number;
  74778. readonly RED_INTEGER: number;
  74779. readonly RG_INTEGER: number;
  74780. readonly RGB_INTEGER: number;
  74781. readonly RGBA_INTEGER: number;
  74782. readonly R8_SNORM: number;
  74783. readonly RG8_SNORM: number;
  74784. readonly RGB8_SNORM: number;
  74785. readonly RGBA8_SNORM: number;
  74786. readonly R8I: number;
  74787. readonly RG8I: number;
  74788. readonly RGB8I: number;
  74789. readonly RGBA8I: number;
  74790. readonly R8UI: number;
  74791. readonly RG8UI: number;
  74792. readonly RGB8UI: number;
  74793. readonly RGBA8UI: number;
  74794. readonly R16I: number;
  74795. readonly RG16I: number;
  74796. readonly RGB16I: number;
  74797. readonly RGBA16I: number;
  74798. readonly R16UI: number;
  74799. readonly RG16UI: number;
  74800. readonly RGB16UI: number;
  74801. readonly RGBA16UI: number;
  74802. readonly R32I: number;
  74803. readonly RG32I: number;
  74804. readonly RGB32I: number;
  74805. readonly RGBA32I: number;
  74806. readonly R32UI: number;
  74807. readonly RG32UI: number;
  74808. readonly RGB32UI: number;
  74809. readonly RGBA32UI: number;
  74810. readonly RGB10_A2UI: number;
  74811. readonly R11F_G11F_B10F: number;
  74812. readonly RGB9_E5: number;
  74813. readonly RGB10_A2: number;
  74814. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74815. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74816. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74817. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74818. readonly DEPTH_COMPONENT32F: number;
  74819. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74820. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74821. 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;
  74822. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74823. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74824. readonly TRANSFORM_FEEDBACK: number;
  74825. readonly INTERLEAVED_ATTRIBS: number;
  74826. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74827. createTransformFeedback(): WebGLTransformFeedback;
  74828. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74829. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74830. beginTransformFeedback(primitiveMode: number): void;
  74831. endTransformFeedback(): void;
  74832. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74833. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74834. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74835. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74836. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74837. }
  74838. interface ImageBitmap {
  74839. readonly width: number;
  74840. readonly height: number;
  74841. close(): void;
  74842. }
  74843. interface WebGLQuery extends WebGLObject {
  74844. }
  74845. declare var WebGLQuery: {
  74846. prototype: WebGLQuery;
  74847. new(): WebGLQuery;
  74848. };
  74849. interface WebGLSampler extends WebGLObject {
  74850. }
  74851. declare var WebGLSampler: {
  74852. prototype: WebGLSampler;
  74853. new(): WebGLSampler;
  74854. };
  74855. interface WebGLSync extends WebGLObject {
  74856. }
  74857. declare var WebGLSync: {
  74858. prototype: WebGLSync;
  74859. new(): WebGLSync;
  74860. };
  74861. interface WebGLTransformFeedback extends WebGLObject {
  74862. }
  74863. declare var WebGLTransformFeedback: {
  74864. prototype: WebGLTransformFeedback;
  74865. new(): WebGLTransformFeedback;
  74866. };
  74867. interface WebGLVertexArrayObject extends WebGLObject {
  74868. }
  74869. declare var WebGLVertexArrayObject: {
  74870. prototype: WebGLVertexArrayObject;
  74871. new(): WebGLVertexArrayObject;
  74872. };
  74873. // Type definitions for WebVR API
  74874. // Project: https://w3c.github.io/webvr/
  74875. // Definitions by: six a <https://github.com/lostfictions>
  74876. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74877. interface VRDisplay extends EventTarget {
  74878. /**
  74879. * Dictionary of capabilities describing the VRDisplay.
  74880. */
  74881. readonly capabilities: VRDisplayCapabilities;
  74882. /**
  74883. * z-depth defining the far plane of the eye view frustum
  74884. * enables mapping of values in the render target depth
  74885. * attachment to scene coordinates. Initially set to 10000.0.
  74886. */
  74887. depthFar: number;
  74888. /**
  74889. * z-depth defining the near plane of the eye view frustum
  74890. * enables mapping of values in the render target depth
  74891. * attachment to scene coordinates. Initially set to 0.01.
  74892. */
  74893. depthNear: number;
  74894. /**
  74895. * An identifier for this distinct VRDisplay. Used as an
  74896. * association point in the Gamepad API.
  74897. */
  74898. readonly displayId: number;
  74899. /**
  74900. * A display name, a user-readable name identifying it.
  74901. */
  74902. readonly displayName: string;
  74903. readonly isConnected: boolean;
  74904. readonly isPresenting: boolean;
  74905. /**
  74906. * If this VRDisplay supports room-scale experiences, the optional
  74907. * stage attribute contains details on the room-scale parameters.
  74908. */
  74909. readonly stageParameters: VRStageParameters | null;
  74910. /**
  74911. * Passing the value returned by `requestAnimationFrame` to
  74912. * `cancelAnimationFrame` will unregister the callback.
  74913. * @param handle Define the hanle of the request to cancel
  74914. */
  74915. cancelAnimationFrame(handle: number): void;
  74916. /**
  74917. * Stops presenting to the VRDisplay.
  74918. * @returns a promise to know when it stopped
  74919. */
  74920. exitPresent(): Promise<void>;
  74921. /**
  74922. * Return the current VREyeParameters for the given eye.
  74923. * @param whichEye Define the eye we want the parameter for
  74924. * @returns the eye parameters
  74925. */
  74926. getEyeParameters(whichEye: string): VREyeParameters;
  74927. /**
  74928. * Populates the passed VRFrameData with the information required to render
  74929. * the current frame.
  74930. * @param frameData Define the data structure to populate
  74931. * @returns true if ok otherwise false
  74932. */
  74933. getFrameData(frameData: VRFrameData): boolean;
  74934. /**
  74935. * Get the layers currently being presented.
  74936. * @returns the list of VR layers
  74937. */
  74938. getLayers(): VRLayer[];
  74939. /**
  74940. * Return a VRPose containing the future predicted pose of the VRDisplay
  74941. * when the current frame will be presented. The value returned will not
  74942. * change until JavaScript has returned control to the browser.
  74943. *
  74944. * The VRPose will contain the position, orientation, velocity,
  74945. * and acceleration of each of these properties.
  74946. * @returns the pose object
  74947. */
  74948. getPose(): VRPose;
  74949. /**
  74950. * Return the current instantaneous pose of the VRDisplay, with no
  74951. * prediction applied.
  74952. * @returns the current instantaneous pose
  74953. */
  74954. getImmediatePose(): VRPose;
  74955. /**
  74956. * The callback passed to `requestAnimationFrame` will be called
  74957. * any time a new frame should be rendered. When the VRDisplay is
  74958. * presenting the callback will be called at the native refresh
  74959. * rate of the HMD. When not presenting this function acts
  74960. * identically to how window.requestAnimationFrame acts. Content should
  74961. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74962. * asynchronously from other displays and at differing refresh rates.
  74963. * @param callback Define the eaction to run next frame
  74964. * @returns the request handle it
  74965. */
  74966. requestAnimationFrame(callback: FrameRequestCallback): number;
  74967. /**
  74968. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74969. * Repeat calls while already presenting will update the VRLayers being displayed.
  74970. * @param layers Define the list of layer to present
  74971. * @returns a promise to know when the request has been fulfilled
  74972. */
  74973. requestPresent(layers: VRLayer[]): Promise<void>;
  74974. /**
  74975. * Reset the pose for this display, treating its current position and
  74976. * orientation as the "origin/zero" values. VRPose.position,
  74977. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74978. * updated when calling resetPose(). This should be called in only
  74979. * sitting-space experiences.
  74980. */
  74981. resetPose(): void;
  74982. /**
  74983. * The VRLayer provided to the VRDisplay will be captured and presented
  74984. * in the HMD. Calling this function has the same effect on the source
  74985. * canvas as any other operation that uses its source image, and canvases
  74986. * created without preserveDrawingBuffer set to true will be cleared.
  74987. * @param pose Define the pose to submit
  74988. */
  74989. submitFrame(pose?: VRPose): void;
  74990. }
  74991. declare var VRDisplay: {
  74992. prototype: VRDisplay;
  74993. new(): VRDisplay;
  74994. };
  74995. interface VRLayer {
  74996. leftBounds?: number[] | Float32Array | null;
  74997. rightBounds?: number[] | Float32Array | null;
  74998. source?: HTMLCanvasElement | null;
  74999. }
  75000. interface VRDisplayCapabilities {
  75001. readonly canPresent: boolean;
  75002. readonly hasExternalDisplay: boolean;
  75003. readonly hasOrientation: boolean;
  75004. readonly hasPosition: boolean;
  75005. readonly maxLayers: number;
  75006. }
  75007. interface VREyeParameters {
  75008. /** @deprecated */
  75009. readonly fieldOfView: VRFieldOfView;
  75010. readonly offset: Float32Array;
  75011. readonly renderHeight: number;
  75012. readonly renderWidth: number;
  75013. }
  75014. interface VRFieldOfView {
  75015. readonly downDegrees: number;
  75016. readonly leftDegrees: number;
  75017. readonly rightDegrees: number;
  75018. readonly upDegrees: number;
  75019. }
  75020. interface VRFrameData {
  75021. readonly leftProjectionMatrix: Float32Array;
  75022. readonly leftViewMatrix: Float32Array;
  75023. readonly pose: VRPose;
  75024. readonly rightProjectionMatrix: Float32Array;
  75025. readonly rightViewMatrix: Float32Array;
  75026. readonly timestamp: number;
  75027. }
  75028. interface VRPose {
  75029. readonly angularAcceleration: Float32Array | null;
  75030. readonly angularVelocity: Float32Array | null;
  75031. readonly linearAcceleration: Float32Array | null;
  75032. readonly linearVelocity: Float32Array | null;
  75033. readonly orientation: Float32Array | null;
  75034. readonly position: Float32Array | null;
  75035. readonly timestamp: number;
  75036. }
  75037. interface VRStageParameters {
  75038. sittingToStandingTransform?: Float32Array;
  75039. sizeX?: number;
  75040. sizeY?: number;
  75041. }
  75042. interface Navigator {
  75043. getVRDisplays(): Promise<VRDisplay[]>;
  75044. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75045. }
  75046. interface Window {
  75047. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75048. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75049. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75050. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75051. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75052. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75053. }
  75054. interface Gamepad {
  75055. readonly displayId: number;
  75056. }
  75057. type XRSessionMode =
  75058. | "inline"
  75059. | "immersive-vr"
  75060. | "immersive-ar";
  75061. type XRReferenceSpaceType =
  75062. | "viewer"
  75063. | "local"
  75064. | "local-floor"
  75065. | "bounded-floor"
  75066. | "unbounded";
  75067. type XREnvironmentBlendMode =
  75068. | "opaque"
  75069. | "additive"
  75070. | "alpha-blend";
  75071. type XRVisibilityState =
  75072. | "visible"
  75073. | "visible-blurred"
  75074. | "hidden";
  75075. type XRHandedness =
  75076. | "none"
  75077. | "left"
  75078. | "right";
  75079. type XRTargetRayMode =
  75080. | "gaze"
  75081. | "tracked-pointer"
  75082. | "screen";
  75083. type XREye =
  75084. | "none"
  75085. | "left"
  75086. | "right";
  75087. type XREventType =
  75088. | "devicechange"
  75089. | "visibilitychange"
  75090. | "end"
  75091. | "inputsourceschange"
  75092. | "select"
  75093. | "selectstart"
  75094. | "selectend"
  75095. | "squeeze"
  75096. | "squeezestart"
  75097. | "squeezeend"
  75098. | "reset";
  75099. interface XRSpace extends EventTarget {
  75100. }
  75101. interface XRRenderState {
  75102. depthNear?: number;
  75103. depthFar?: number;
  75104. inlineVerticalFieldOfView?: number;
  75105. baseLayer?: XRWebGLLayer;
  75106. }
  75107. interface XRInputSource {
  75108. handedness: XRHandedness;
  75109. targetRayMode: XRTargetRayMode;
  75110. targetRaySpace: XRSpace;
  75111. gripSpace: XRSpace | undefined;
  75112. gamepad: Gamepad | undefined;
  75113. profiles: Array<string>;
  75114. }
  75115. interface XRSessionInit {
  75116. optionalFeatures?: string[];
  75117. requiredFeatures?: string[];
  75118. }
  75119. interface XRSession {
  75120. addEventListener: Function;
  75121. removeEventListener: Function;
  75122. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75123. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75124. requestAnimationFrame: Function;
  75125. end(): Promise<void>;
  75126. renderState: XRRenderState;
  75127. inputSources: Array<XRInputSource>;
  75128. // hit test
  75129. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75130. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75131. // legacy AR hit test
  75132. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75133. // legacy plane detection
  75134. updateWorldTrackingState(options: {
  75135. planeDetectionState?: { enabled: boolean; }
  75136. }): void;
  75137. }
  75138. interface XRReferenceSpace extends XRSpace {
  75139. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75140. onreset: any;
  75141. }
  75142. type XRPlaneSet = Set<XRPlane>;
  75143. type XRAnchorSet = Set<XRAnchor>;
  75144. interface XRFrame {
  75145. session: XRSession;
  75146. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75147. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75148. // AR
  75149. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  75150. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75151. // Anchors
  75152. trackedAnchors?: XRAnchorSet;
  75153. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75154. // Planes
  75155. worldInformation: {
  75156. detectedPlanes?: XRPlaneSet;
  75157. };
  75158. }
  75159. interface XRViewerPose extends XRPose {
  75160. views: Array<XRView>;
  75161. }
  75162. interface XRPose {
  75163. transform: XRRigidTransform;
  75164. emulatedPosition: boolean;
  75165. }
  75166. interface XRWebGLLayerOptions {
  75167. antialias?: boolean;
  75168. depth?: boolean;
  75169. stencil?: boolean;
  75170. alpha?: boolean;
  75171. multiview?: boolean;
  75172. framebufferScaleFactor?: number;
  75173. }
  75174. declare var XRWebGLLayer: {
  75175. prototype: XRWebGLLayer;
  75176. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75177. };
  75178. interface XRWebGLLayer {
  75179. framebuffer: WebGLFramebuffer;
  75180. framebufferWidth: number;
  75181. framebufferHeight: number;
  75182. getViewport: Function;
  75183. }
  75184. declare class XRRigidTransform {
  75185. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75186. position: DOMPointReadOnly;
  75187. orientation: DOMPointReadOnly;
  75188. matrix: Float32Array;
  75189. inverse: XRRigidTransform;
  75190. }
  75191. interface XRView {
  75192. eye: XREye;
  75193. projectionMatrix: Float32Array;
  75194. transform: XRRigidTransform;
  75195. }
  75196. interface XRInputSourceChangeEvent {
  75197. session: XRSession;
  75198. removed: Array<XRInputSource>;
  75199. added: Array<XRInputSource>;
  75200. }
  75201. interface XRInputSourceEvent extends Event {
  75202. readonly frame: XRFrame;
  75203. readonly inputSource: XRInputSource;
  75204. }
  75205. // Experimental(er) features
  75206. declare class XRRay {
  75207. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75208. origin: DOMPointReadOnly;
  75209. direction: DOMPointReadOnly;
  75210. matrix: Float32Array;
  75211. }
  75212. declare enum XRHitTestTrackableType {
  75213. "point",
  75214. "plane"
  75215. }
  75216. interface XRHitResult {
  75217. hitMatrix: Float32Array;
  75218. }
  75219. interface XRTransientInputHitTestResult {
  75220. readonly inputSource: XRInputSource;
  75221. readonly results: Array<XRHitTestResult>;
  75222. }
  75223. interface XRHitTestResult {
  75224. getPose(baseSpace: XRSpace): XRPose | undefined;
  75225. // When anchor system is enabled
  75226. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75227. }
  75228. interface XRHitTestSource {
  75229. cancel(): void;
  75230. }
  75231. interface XRTransientInputHitTestSource {
  75232. cancel(): void;
  75233. }
  75234. interface XRHitTestOptionsInit {
  75235. space: XRSpace;
  75236. entityTypes?: Array<XRHitTestTrackableType>;
  75237. offsetRay?: XRRay;
  75238. }
  75239. interface XRTransientInputHitTestOptionsInit {
  75240. profile: string;
  75241. entityTypes?: Array<XRHitTestTrackableType>;
  75242. offsetRay?: XRRay;
  75243. }
  75244. interface XRAnchor {
  75245. anchorSpace: XRSpace;
  75246. delete(): void;
  75247. }
  75248. interface XRPlane {
  75249. orientation: "Horizontal" | "Vertical";
  75250. planeSpace: XRSpace;
  75251. polygon: Array<DOMPointReadOnly>;
  75252. lastChangedTime: number;
  75253. }
  75254. /**
  75255. * @ignore
  75256. */
  75257. declare module BABYLON.GLTF2.Exporter {
  75258. }
  75259. /**
  75260. * @ignore
  75261. */
  75262. declare module BABYLON.GLTF1 {
  75263. }
  75264. declare module BABYLON.GUI {
  75265. /**
  75266. * Class used to specific a value and its associated unit
  75267. */
  75268. export class ValueAndUnit {
  75269. /** defines the unit to store */
  75270. unit: number;
  75271. /** defines a boolean indicating if the value can be negative */
  75272. negativeValueAllowed: boolean;
  75273. private _value;
  75274. private _originalUnit;
  75275. /**
  75276. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75277. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75278. */
  75279. ignoreAdaptiveScaling: boolean;
  75280. /**
  75281. * Creates a new ValueAndUnit
  75282. * @param value defines the value to store
  75283. * @param unit defines the unit to store
  75284. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75285. */
  75286. constructor(value: number,
  75287. /** defines the unit to store */
  75288. unit?: number,
  75289. /** defines a boolean indicating if the value can be negative */
  75290. negativeValueAllowed?: boolean);
  75291. /** Gets a boolean indicating if the value is a percentage */
  75292. get isPercentage(): boolean;
  75293. /** Gets a boolean indicating if the value is store as pixel */
  75294. get isPixel(): boolean;
  75295. /** Gets direct internal value */
  75296. get internalValue(): number;
  75297. /**
  75298. * Gets value as pixel
  75299. * @param host defines the root host
  75300. * @param refValue defines the reference value for percentages
  75301. * @returns the value as pixel
  75302. */
  75303. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75304. /**
  75305. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75306. * @param value defines the value to store
  75307. * @param unit defines the unit to store
  75308. * @returns the current ValueAndUnit
  75309. */
  75310. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75311. /**
  75312. * Gets the value accordingly to its unit
  75313. * @param host defines the root host
  75314. * @returns the value
  75315. */
  75316. getValue(host: AdvancedDynamicTexture): number;
  75317. /**
  75318. * Gets a string representation of the value
  75319. * @param host defines the root host
  75320. * @param decimals defines an optional number of decimals to display
  75321. * @returns a string
  75322. */
  75323. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75324. /**
  75325. * Store a value parsed from a string
  75326. * @param source defines the source string
  75327. * @returns true if the value was successfully parsed
  75328. */
  75329. fromString(source: string | number): boolean;
  75330. private static _Regex;
  75331. private static _UNITMODE_PERCENTAGE;
  75332. private static _UNITMODE_PIXEL;
  75333. /** UNITMODE_PERCENTAGE */
  75334. static get UNITMODE_PERCENTAGE(): number;
  75335. /** UNITMODE_PIXEL */
  75336. static get UNITMODE_PIXEL(): number;
  75337. }
  75338. }
  75339. declare module BABYLON.GUI {
  75340. /**
  75341. * Define a style used by control to automatically setup properties based on a template.
  75342. * Only support font related properties so far
  75343. */
  75344. export class Style implements BABYLON.IDisposable {
  75345. private _fontFamily;
  75346. private _fontStyle;
  75347. private _fontWeight;
  75348. /** @hidden */
  75349. _host: AdvancedDynamicTexture;
  75350. /** @hidden */
  75351. _fontSize: ValueAndUnit;
  75352. /**
  75353. * BABYLON.Observable raised when the style values are changed
  75354. */
  75355. onChangedObservable: BABYLON.Observable<Style>;
  75356. /**
  75357. * Creates a new style object
  75358. * @param host defines the AdvancedDynamicTexture which hosts this style
  75359. */
  75360. constructor(host: AdvancedDynamicTexture);
  75361. /**
  75362. * Gets or sets the font size
  75363. */
  75364. get fontSize(): string | number;
  75365. set fontSize(value: string | number);
  75366. /**
  75367. * Gets or sets the font family
  75368. */
  75369. get fontFamily(): string;
  75370. set fontFamily(value: string);
  75371. /**
  75372. * Gets or sets the font style
  75373. */
  75374. get fontStyle(): string;
  75375. set fontStyle(value: string);
  75376. /** Gets or sets font weight */
  75377. get fontWeight(): string;
  75378. set fontWeight(value: string);
  75379. /** Dispose all associated resources */
  75380. dispose(): void;
  75381. }
  75382. }
  75383. declare module BABYLON.GUI {
  75384. /**
  75385. * Class used to transport BABYLON.Vector2 information for pointer events
  75386. */
  75387. export class Vector2WithInfo extends BABYLON.Vector2 {
  75388. /** defines the current mouse button index */
  75389. buttonIndex: number;
  75390. /**
  75391. * Creates a new Vector2WithInfo
  75392. * @param source defines the vector2 data to transport
  75393. * @param buttonIndex defines the current mouse button index
  75394. */
  75395. constructor(source: BABYLON.Vector2,
  75396. /** defines the current mouse button index */
  75397. buttonIndex?: number);
  75398. }
  75399. /** Class used to provide 2D matrix features */
  75400. export class Matrix2D {
  75401. /** Gets the internal array of 6 floats used to store matrix data */
  75402. m: Float32Array;
  75403. /**
  75404. * Creates a new matrix
  75405. * @param m00 defines value for (0, 0)
  75406. * @param m01 defines value for (0, 1)
  75407. * @param m10 defines value for (1, 0)
  75408. * @param m11 defines value for (1, 1)
  75409. * @param m20 defines value for (2, 0)
  75410. * @param m21 defines value for (2, 1)
  75411. */
  75412. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75413. /**
  75414. * Fills the matrix from direct values
  75415. * @param m00 defines value for (0, 0)
  75416. * @param m01 defines value for (0, 1)
  75417. * @param m10 defines value for (1, 0)
  75418. * @param m11 defines value for (1, 1)
  75419. * @param m20 defines value for (2, 0)
  75420. * @param m21 defines value for (2, 1)
  75421. * @returns the current modified matrix
  75422. */
  75423. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75424. /**
  75425. * Gets matrix determinant
  75426. * @returns the determinant
  75427. */
  75428. determinant(): number;
  75429. /**
  75430. * Inverses the matrix and stores it in a target matrix
  75431. * @param result defines the target matrix
  75432. * @returns the current matrix
  75433. */
  75434. invertToRef(result: Matrix2D): Matrix2D;
  75435. /**
  75436. * Multiplies the current matrix with another one
  75437. * @param other defines the second operand
  75438. * @param result defines the target matrix
  75439. * @returns the current matrix
  75440. */
  75441. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75442. /**
  75443. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75444. * @param x defines the x coordinate to transform
  75445. * @param y defines the x coordinate to transform
  75446. * @param result defines the target vector2
  75447. * @returns the current matrix
  75448. */
  75449. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75450. /**
  75451. * Creates an identity matrix
  75452. * @returns a new matrix
  75453. */
  75454. static Identity(): Matrix2D;
  75455. /**
  75456. * Creates a translation matrix and stores it in a target matrix
  75457. * @param x defines the x coordinate of the translation
  75458. * @param y defines the y coordinate of the translation
  75459. * @param result defines the target matrix
  75460. */
  75461. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75462. /**
  75463. * Creates a scaling matrix and stores it in a target matrix
  75464. * @param x defines the x coordinate of the scaling
  75465. * @param y defines the y coordinate of the scaling
  75466. * @param result defines the target matrix
  75467. */
  75468. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75469. /**
  75470. * Creates a rotation matrix and stores it in a target matrix
  75471. * @param angle defines the rotation angle
  75472. * @param result defines the target matrix
  75473. */
  75474. static RotationToRef(angle: number, result: Matrix2D): void;
  75475. private static _TempPreTranslationMatrix;
  75476. private static _TempPostTranslationMatrix;
  75477. private static _TempRotationMatrix;
  75478. private static _TempScalingMatrix;
  75479. private static _TempCompose0;
  75480. private static _TempCompose1;
  75481. private static _TempCompose2;
  75482. /**
  75483. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75484. * @param tx defines the x coordinate of the translation
  75485. * @param ty defines the y coordinate of the translation
  75486. * @param angle defines the rotation angle
  75487. * @param scaleX defines the x coordinate of the scaling
  75488. * @param scaleY defines the y coordinate of the scaling
  75489. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75490. * @param result defines the target matrix
  75491. */
  75492. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75493. }
  75494. }
  75495. declare module BABYLON.GUI {
  75496. /**
  75497. * Class used to store 2D control sizes
  75498. */
  75499. export class Measure {
  75500. /** defines left coordinate */
  75501. left: number;
  75502. /** defines top coordinate */
  75503. top: number;
  75504. /** defines width dimension */
  75505. width: number;
  75506. /** defines height dimension */
  75507. height: number;
  75508. /**
  75509. * Creates a new measure
  75510. * @param left defines left coordinate
  75511. * @param top defines top coordinate
  75512. * @param width defines width dimension
  75513. * @param height defines height dimension
  75514. */
  75515. constructor(
  75516. /** defines left coordinate */
  75517. left: number,
  75518. /** defines top coordinate */
  75519. top: number,
  75520. /** defines width dimension */
  75521. width: number,
  75522. /** defines height dimension */
  75523. height: number);
  75524. /**
  75525. * Copy from another measure
  75526. * @param other defines the other measure to copy from
  75527. */
  75528. copyFrom(other: Measure): void;
  75529. /**
  75530. * Copy from a group of 4 floats
  75531. * @param left defines left coordinate
  75532. * @param top defines top coordinate
  75533. * @param width defines width dimension
  75534. * @param height defines height dimension
  75535. */
  75536. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75537. /**
  75538. * Computes the axis aligned bounding box measure for two given measures
  75539. * @param a Input measure
  75540. * @param b Input measure
  75541. * @param result the resulting bounding measure
  75542. */
  75543. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75544. /**
  75545. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75546. * @param transform the matrix to transform the measure before computing the AABB
  75547. * @param result the resulting AABB
  75548. */
  75549. transformToRef(transform: Matrix2D, result: Measure): void;
  75550. /**
  75551. * Check equality between this measure and another one
  75552. * @param other defines the other measures
  75553. * @returns true if both measures are equals
  75554. */
  75555. isEqualsTo(other: Measure): boolean;
  75556. /**
  75557. * Creates an empty measure
  75558. * @returns a new measure
  75559. */
  75560. static Empty(): Measure;
  75561. }
  75562. }
  75563. declare module BABYLON.GUI {
  75564. /**
  75565. * Interface used to define a control that can receive focus
  75566. */
  75567. export interface IFocusableControl {
  75568. /**
  75569. * Function called when the control receives the focus
  75570. */
  75571. onFocus(): void;
  75572. /**
  75573. * Function called when the control loses the focus
  75574. */
  75575. onBlur(): void;
  75576. /**
  75577. * Function called to let the control handle keyboard events
  75578. * @param evt defines the current keyboard event
  75579. */
  75580. processKeyboard(evt: KeyboardEvent): void;
  75581. /**
  75582. * Function called to get the list of controls that should not steal the focus from this control
  75583. * @returns an array of controls
  75584. */
  75585. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75586. }
  75587. /**
  75588. * Class used to create texture to support 2D GUI elements
  75589. * @see https://doc.babylonjs.com/how_to/gui
  75590. */
  75591. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75592. private _isDirty;
  75593. private _renderObserver;
  75594. private _resizeObserver;
  75595. private _preKeyboardObserver;
  75596. private _pointerMoveObserver;
  75597. private _pointerObserver;
  75598. private _canvasPointerOutObserver;
  75599. private _background;
  75600. /** @hidden */
  75601. _rootContainer: Container;
  75602. /** @hidden */
  75603. _lastPickedControl: Control;
  75604. /** @hidden */
  75605. _lastControlOver: {
  75606. [pointerId: number]: Control;
  75607. };
  75608. /** @hidden */
  75609. _lastControlDown: {
  75610. [pointerId: number]: Control;
  75611. };
  75612. /** @hidden */
  75613. _capturingControl: {
  75614. [pointerId: number]: Control;
  75615. };
  75616. /** @hidden */
  75617. _shouldBlockPointer: boolean;
  75618. /** @hidden */
  75619. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75620. /** @hidden */
  75621. _linkedControls: Control[];
  75622. private _isFullscreen;
  75623. private _fullscreenViewport;
  75624. private _idealWidth;
  75625. private _idealHeight;
  75626. private _useSmallestIdeal;
  75627. private _renderAtIdealSize;
  75628. private _focusedControl;
  75629. private _blockNextFocusCheck;
  75630. private _renderScale;
  75631. private _rootElement;
  75632. private _cursorChanged;
  75633. private _defaultMousePointerId;
  75634. /** @hidden */
  75635. _numLayoutCalls: number;
  75636. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75637. get numLayoutCalls(): number;
  75638. /** @hidden */
  75639. _numRenderCalls: number;
  75640. /** Gets the number of render calls made the last time the ADT has been rendered */
  75641. get numRenderCalls(): number;
  75642. /**
  75643. * Define type to string to ensure compatibility across browsers
  75644. * Safari doesn't support DataTransfer constructor
  75645. */
  75646. private _clipboardData;
  75647. /**
  75648. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75649. */
  75650. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75651. /**
  75652. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75653. */
  75654. onControlPickedObservable: BABYLON.Observable<Control>;
  75655. /**
  75656. * BABYLON.Observable event triggered before layout is evaluated
  75657. */
  75658. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75659. /**
  75660. * BABYLON.Observable event triggered after the layout was evaluated
  75661. */
  75662. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75663. /**
  75664. * BABYLON.Observable event triggered before the texture is rendered
  75665. */
  75666. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75667. /**
  75668. * BABYLON.Observable event triggered after the texture was rendered
  75669. */
  75670. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75671. /**
  75672. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75673. */
  75674. premulAlpha: boolean;
  75675. /**
  75676. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75677. * Useful when you want more antialiasing
  75678. */
  75679. get renderScale(): number;
  75680. set renderScale(value: number);
  75681. /** Gets or sets the background color */
  75682. get background(): string;
  75683. set background(value: string);
  75684. /**
  75685. * Gets or sets the ideal width used to design controls.
  75686. * The GUI will then rescale everything accordingly
  75687. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75688. */
  75689. get idealWidth(): number;
  75690. set idealWidth(value: number);
  75691. /**
  75692. * Gets or sets the ideal height used to design controls.
  75693. * The GUI will then rescale everything accordingly
  75694. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75695. */
  75696. get idealHeight(): number;
  75697. set idealHeight(value: number);
  75698. /**
  75699. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75700. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75701. */
  75702. get useSmallestIdeal(): boolean;
  75703. set useSmallestIdeal(value: boolean);
  75704. /**
  75705. * Gets or sets a boolean indicating if adaptive scaling must be used
  75706. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75707. */
  75708. get renderAtIdealSize(): boolean;
  75709. set renderAtIdealSize(value: boolean);
  75710. /**
  75711. * Gets the ratio used when in "ideal mode"
  75712. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75713. * */
  75714. get idealRatio(): number;
  75715. /**
  75716. * Gets the underlying layer used to render the texture when in fullscreen mode
  75717. */
  75718. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75719. /**
  75720. * Gets the root container control
  75721. */
  75722. get rootContainer(): Container;
  75723. /**
  75724. * Returns an array containing the root container.
  75725. * This is mostly used to let the Inspector introspects the ADT
  75726. * @returns an array containing the rootContainer
  75727. */
  75728. getChildren(): Array<Container>;
  75729. /**
  75730. * Will return all controls that are inside this texture
  75731. * @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
  75732. * @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
  75733. * @return all child controls
  75734. */
  75735. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75736. /**
  75737. * Gets or sets the current focused control
  75738. */
  75739. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75740. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75741. /**
  75742. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75743. */
  75744. get isForeground(): boolean;
  75745. set isForeground(value: boolean);
  75746. /**
  75747. * Gets or set information about clipboardData
  75748. */
  75749. get clipboardData(): string;
  75750. set clipboardData(value: string);
  75751. /**
  75752. * Creates a new AdvancedDynamicTexture
  75753. * @param name defines the name of the texture
  75754. * @param width defines the width of the texture
  75755. * @param height defines the height of the texture
  75756. * @param scene defines the hosting scene
  75757. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75758. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75759. */
  75760. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75761. /**
  75762. * Get the current class name of the texture useful for serialization or dynamic coding.
  75763. * @returns "AdvancedDynamicTexture"
  75764. */
  75765. getClassName(): string;
  75766. /**
  75767. * Function used to execute a function on all controls
  75768. * @param func defines the function to execute
  75769. * @param container defines the container where controls belong. If null the root container will be used
  75770. */
  75771. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75772. private _useInvalidateRectOptimization;
  75773. /**
  75774. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75775. */
  75776. get useInvalidateRectOptimization(): boolean;
  75777. set useInvalidateRectOptimization(value: boolean);
  75778. private _invalidatedRectangle;
  75779. /**
  75780. * Invalidates a rectangle area on the gui texture
  75781. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75782. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75783. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75784. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75785. */
  75786. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75787. /**
  75788. * Marks the texture as dirty forcing a complete update
  75789. */
  75790. markAsDirty(): void;
  75791. /**
  75792. * Helper function used to create a new style
  75793. * @returns a new style
  75794. * @see https://doc.babylonjs.com/how_to/gui#styles
  75795. */
  75796. createStyle(): Style;
  75797. /**
  75798. * Adds a new control to the root container
  75799. * @param control defines the control to add
  75800. * @returns the current texture
  75801. */
  75802. addControl(control: Control): AdvancedDynamicTexture;
  75803. /**
  75804. * Removes a control from the root container
  75805. * @param control defines the control to remove
  75806. * @returns the current texture
  75807. */
  75808. removeControl(control: Control): AdvancedDynamicTexture;
  75809. /**
  75810. * Release all resources
  75811. */
  75812. dispose(): void;
  75813. private _onResize;
  75814. /** @hidden */
  75815. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75816. /**
  75817. * Get screen coordinates for a vector3
  75818. * @param position defines the position to project
  75819. * @param worldMatrix defines the world matrix to use
  75820. * @returns the projected position
  75821. */
  75822. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75823. private _checkUpdate;
  75824. private _clearMeasure;
  75825. private _render;
  75826. /** @hidden */
  75827. _changeCursor(cursor: string): void;
  75828. /** @hidden */
  75829. _registerLastControlDown(control: Control, pointerId: number): void;
  75830. private _doPicking;
  75831. /** @hidden */
  75832. _cleanControlAfterRemovalFromList(list: {
  75833. [pointerId: number]: Control;
  75834. }, control: Control): void;
  75835. /** @hidden */
  75836. _cleanControlAfterRemoval(control: Control): void;
  75837. /** Attach to all scene events required to support pointer events */
  75838. attach(): void;
  75839. /** @hidden */
  75840. private onClipboardCopy;
  75841. /** @hidden */
  75842. private onClipboardCut;
  75843. /** @hidden */
  75844. private onClipboardPaste;
  75845. /**
  75846. * Register the clipboard Events onto the canvas
  75847. */
  75848. registerClipboardEvents(): void;
  75849. /**
  75850. * Unregister the clipboard Events from the canvas
  75851. */
  75852. unRegisterClipboardEvents(): void;
  75853. /**
  75854. * Connect the texture to a hosting mesh to enable interactions
  75855. * @param mesh defines the mesh to attach to
  75856. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75857. */
  75858. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75859. /**
  75860. * Move the focus to a specific control
  75861. * @param control defines the control which will receive the focus
  75862. */
  75863. moveFocusToControl(control: IFocusableControl): void;
  75864. private _manageFocus;
  75865. private _attachToOnPointerOut;
  75866. /**
  75867. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75868. * @param mesh defines the mesh which will receive the texture
  75869. * @param width defines the texture width (1024 by default)
  75870. * @param height defines the texture height (1024 by default)
  75871. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75872. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75873. * @returns a new AdvancedDynamicTexture
  75874. */
  75875. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75876. /**
  75877. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75878. * In this mode the texture will rely on a layer for its rendering.
  75879. * This allows it to be treated like any other layer.
  75880. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75881. * LayerMask is set through advancedTexture.layer.layerMask
  75882. * @param name defines name for the texture
  75883. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75884. * @param scene defines the hsoting scene
  75885. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75886. * @returns a new AdvancedDynamicTexture
  75887. */
  75888. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75889. }
  75890. }
  75891. declare module BABYLON.GUI {
  75892. /**
  75893. * Root class used for all 2D controls
  75894. * @see https://doc.babylonjs.com/how_to/gui#controls
  75895. */
  75896. export class Control {
  75897. /** defines the name of the control */
  75898. name?: string | undefined;
  75899. /**
  75900. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75901. */
  75902. static AllowAlphaInheritance: boolean;
  75903. private _alpha;
  75904. private _alphaSet;
  75905. private _zIndex;
  75906. /** @hidden */
  75907. _host: AdvancedDynamicTexture;
  75908. /** Gets or sets the control parent */
  75909. parent: BABYLON.Nullable<Container>;
  75910. /** @hidden */
  75911. _currentMeasure: Measure;
  75912. private _fontFamily;
  75913. private _fontStyle;
  75914. private _fontWeight;
  75915. private _fontSize;
  75916. private _font;
  75917. /** @hidden */
  75918. _width: ValueAndUnit;
  75919. /** @hidden */
  75920. _height: ValueAndUnit;
  75921. /** @hidden */
  75922. protected _fontOffset: {
  75923. ascent: number;
  75924. height: number;
  75925. descent: number;
  75926. };
  75927. private _color;
  75928. private _style;
  75929. private _styleObserver;
  75930. /** @hidden */
  75931. protected _horizontalAlignment: number;
  75932. /** @hidden */
  75933. protected _verticalAlignment: number;
  75934. /** @hidden */
  75935. protected _isDirty: boolean;
  75936. /** @hidden */
  75937. protected _wasDirty: boolean;
  75938. /** @hidden */
  75939. _tempParentMeasure: Measure;
  75940. /** @hidden */
  75941. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75942. /** @hidden */
  75943. protected _cachedParentMeasure: Measure;
  75944. private _paddingLeft;
  75945. private _paddingRight;
  75946. private _paddingTop;
  75947. private _paddingBottom;
  75948. /** @hidden */
  75949. _left: ValueAndUnit;
  75950. /** @hidden */
  75951. _top: ValueAndUnit;
  75952. private _scaleX;
  75953. private _scaleY;
  75954. private _rotation;
  75955. private _transformCenterX;
  75956. private _transformCenterY;
  75957. /** @hidden */
  75958. _transformMatrix: Matrix2D;
  75959. /** @hidden */
  75960. protected _invertTransformMatrix: Matrix2D;
  75961. /** @hidden */
  75962. protected _transformedPosition: BABYLON.Vector2;
  75963. private _isMatrixDirty;
  75964. private _cachedOffsetX;
  75965. private _cachedOffsetY;
  75966. private _isVisible;
  75967. private _isHighlighted;
  75968. /** @hidden */
  75969. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75970. private _fontSet;
  75971. private _dummyVector2;
  75972. private _downCount;
  75973. private _enterCount;
  75974. private _doNotRender;
  75975. private _downPointerIds;
  75976. protected _isEnabled: boolean;
  75977. protected _disabledColor: string;
  75978. protected _disabledColorItem: string;
  75979. /** @hidden */
  75980. protected _rebuildLayout: boolean;
  75981. /** @hidden */
  75982. _customData: any;
  75983. /** @hidden */
  75984. _isClipped: boolean;
  75985. /** @hidden */
  75986. _automaticSize: boolean;
  75987. /** @hidden */
  75988. _tag: any;
  75989. /**
  75990. * 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
  75991. */
  75992. uniqueId: number;
  75993. /**
  75994. * Gets or sets an object used to store user defined information for the node
  75995. */
  75996. metadata: any;
  75997. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75998. isHitTestVisible: boolean;
  75999. /** Gets or sets a boolean indicating if the control can block pointer events */
  76000. isPointerBlocker: boolean;
  76001. /** Gets or sets a boolean indicating if the control can be focusable */
  76002. isFocusInvisible: boolean;
  76003. /**
  76004. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76005. * 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
  76006. */
  76007. clipChildren: boolean;
  76008. /**
  76009. * Gets or sets a boolean indicating that control content must be clipped
  76010. * 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
  76011. */
  76012. clipContent: boolean;
  76013. /**
  76014. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76015. */
  76016. useBitmapCache: boolean;
  76017. private _cacheData;
  76018. private _shadowOffsetX;
  76019. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76020. get shadowOffsetX(): number;
  76021. set shadowOffsetX(value: number);
  76022. private _shadowOffsetY;
  76023. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76024. get shadowOffsetY(): number;
  76025. set shadowOffsetY(value: number);
  76026. private _shadowBlur;
  76027. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76028. get shadowBlur(): number;
  76029. set shadowBlur(value: number);
  76030. private _shadowColor;
  76031. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76032. get shadowColor(): string;
  76033. set shadowColor(value: string);
  76034. /** Gets or sets the cursor to use when the control is hovered */
  76035. hoverCursor: string;
  76036. /** @hidden */
  76037. protected _linkOffsetX: ValueAndUnit;
  76038. /** @hidden */
  76039. protected _linkOffsetY: ValueAndUnit;
  76040. /** Gets the control type name */
  76041. get typeName(): string;
  76042. /**
  76043. * Get the current class name of the control.
  76044. * @returns current class name
  76045. */
  76046. getClassName(): string;
  76047. /**
  76048. * An event triggered when pointer wheel is scrolled
  76049. */
  76050. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76051. /**
  76052. * An event triggered when the pointer move over the control.
  76053. */
  76054. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76055. /**
  76056. * An event triggered when the pointer move out of the control.
  76057. */
  76058. onPointerOutObservable: BABYLON.Observable<Control>;
  76059. /**
  76060. * An event triggered when the pointer taps the control
  76061. */
  76062. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76063. /**
  76064. * An event triggered when pointer up
  76065. */
  76066. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76067. /**
  76068. * An event triggered when a control is clicked on
  76069. */
  76070. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76071. /**
  76072. * An event triggered when pointer enters the control
  76073. */
  76074. onPointerEnterObservable: BABYLON.Observable<Control>;
  76075. /**
  76076. * An event triggered when the control is marked as dirty
  76077. */
  76078. onDirtyObservable: BABYLON.Observable<Control>;
  76079. /**
  76080. * An event triggered before drawing the control
  76081. */
  76082. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76083. /**
  76084. * An event triggered after the control was drawn
  76085. */
  76086. onAfterDrawObservable: BABYLON.Observable<Control>;
  76087. /**
  76088. * An event triggered when the control has been disposed
  76089. */
  76090. onDisposeObservable: BABYLON.Observable<Control>;
  76091. /**
  76092. * Get the hosting AdvancedDynamicTexture
  76093. */
  76094. get host(): AdvancedDynamicTexture;
  76095. /** Gets or set information about font offsets (used to render and align text) */
  76096. get fontOffset(): {
  76097. ascent: number;
  76098. height: number;
  76099. descent: number;
  76100. };
  76101. set fontOffset(offset: {
  76102. ascent: number;
  76103. height: number;
  76104. descent: number;
  76105. });
  76106. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76107. get alpha(): number;
  76108. set alpha(value: number);
  76109. /**
  76110. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76111. */
  76112. get isHighlighted(): boolean;
  76113. set isHighlighted(value: boolean);
  76114. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76115. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76116. */
  76117. get scaleX(): number;
  76118. set scaleX(value: number);
  76119. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76120. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76121. */
  76122. get scaleY(): number;
  76123. set scaleY(value: number);
  76124. /** Gets or sets the rotation angle (0 by default)
  76125. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76126. */
  76127. get rotation(): number;
  76128. set rotation(value: number);
  76129. /** Gets or sets the transformation center on Y axis (0 by default)
  76130. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76131. */
  76132. get transformCenterY(): number;
  76133. set transformCenterY(value: number);
  76134. /** Gets or sets the transformation center on X axis (0 by default)
  76135. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76136. */
  76137. get transformCenterX(): number;
  76138. set transformCenterX(value: number);
  76139. /**
  76140. * Gets or sets the horizontal alignment
  76141. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76142. */
  76143. get horizontalAlignment(): number;
  76144. set horizontalAlignment(value: number);
  76145. /**
  76146. * Gets or sets the vertical alignment
  76147. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76148. */
  76149. get verticalAlignment(): number;
  76150. set verticalAlignment(value: number);
  76151. /**
  76152. * Gets or sets control width
  76153. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76154. */
  76155. get width(): string | number;
  76156. set width(value: string | number);
  76157. /**
  76158. * Gets or sets the control width in pixel
  76159. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76160. */
  76161. get widthInPixels(): number;
  76162. set widthInPixels(value: number);
  76163. /**
  76164. * Gets or sets control height
  76165. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76166. */
  76167. get height(): string | number;
  76168. set height(value: string | number);
  76169. /**
  76170. * Gets or sets control height in pixel
  76171. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76172. */
  76173. get heightInPixels(): number;
  76174. set heightInPixels(value: number);
  76175. /** Gets or set font family */
  76176. get fontFamily(): string;
  76177. set fontFamily(value: string);
  76178. /** Gets or sets font style */
  76179. get fontStyle(): string;
  76180. set fontStyle(value: string);
  76181. /** Gets or sets font weight */
  76182. get fontWeight(): string;
  76183. set fontWeight(value: string);
  76184. /**
  76185. * Gets or sets style
  76186. * @see https://doc.babylonjs.com/how_to/gui#styles
  76187. */
  76188. get style(): BABYLON.Nullable<Style>;
  76189. set style(value: BABYLON.Nullable<Style>);
  76190. /** @hidden */
  76191. get _isFontSizeInPercentage(): boolean;
  76192. /** Gets or sets font size in pixels */
  76193. get fontSizeInPixels(): number;
  76194. set fontSizeInPixels(value: number);
  76195. /** Gets or sets font size */
  76196. get fontSize(): string | number;
  76197. set fontSize(value: string | number);
  76198. /** Gets or sets foreground color */
  76199. get color(): string;
  76200. set color(value: string);
  76201. /** Gets or sets z index which is used to reorder controls on the z axis */
  76202. get zIndex(): number;
  76203. set zIndex(value: number);
  76204. /** Gets or sets a boolean indicating if the control can be rendered */
  76205. get notRenderable(): boolean;
  76206. set notRenderable(value: boolean);
  76207. /** Gets or sets a boolean indicating if the control is visible */
  76208. get isVisible(): boolean;
  76209. set isVisible(value: boolean);
  76210. /** Gets a boolean indicating that the control needs to update its rendering */
  76211. get isDirty(): boolean;
  76212. /**
  76213. * Gets the current linked mesh (or null if none)
  76214. */
  76215. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76216. /**
  76217. * Gets or sets a value indicating the padding to use on the left of the control
  76218. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76219. */
  76220. get paddingLeft(): string | number;
  76221. set paddingLeft(value: string | number);
  76222. /**
  76223. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76224. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76225. */
  76226. get paddingLeftInPixels(): number;
  76227. set paddingLeftInPixels(value: number);
  76228. /**
  76229. * Gets or sets a value indicating the padding to use on the right of the control
  76230. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76231. */
  76232. get paddingRight(): string | number;
  76233. set paddingRight(value: string | number);
  76234. /**
  76235. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76236. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76237. */
  76238. get paddingRightInPixels(): number;
  76239. set paddingRightInPixels(value: number);
  76240. /**
  76241. * Gets or sets a value indicating the padding to use on the top of the control
  76242. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76243. */
  76244. get paddingTop(): string | number;
  76245. set paddingTop(value: string | number);
  76246. /**
  76247. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76248. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76249. */
  76250. get paddingTopInPixels(): number;
  76251. set paddingTopInPixels(value: number);
  76252. /**
  76253. * Gets or sets a value indicating the padding to use on the bottom of the control
  76254. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76255. */
  76256. get paddingBottom(): string | number;
  76257. set paddingBottom(value: string | number);
  76258. /**
  76259. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76260. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76261. */
  76262. get paddingBottomInPixels(): number;
  76263. set paddingBottomInPixels(value: number);
  76264. /**
  76265. * Gets or sets a value indicating the left coordinate of the control
  76266. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76267. */
  76268. get left(): string | number;
  76269. set left(value: string | number);
  76270. /**
  76271. * Gets or sets a value indicating the left coordinate in pixels of the control
  76272. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76273. */
  76274. get leftInPixels(): number;
  76275. set leftInPixels(value: number);
  76276. /**
  76277. * Gets or sets a value indicating the top coordinate of the control
  76278. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76279. */
  76280. get top(): string | number;
  76281. set top(value: string | number);
  76282. /**
  76283. * Gets or sets a value indicating the top coordinate in pixels of the control
  76284. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76285. */
  76286. get topInPixels(): number;
  76287. set topInPixels(value: number);
  76288. /**
  76289. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76290. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76291. */
  76292. get linkOffsetX(): string | number;
  76293. set linkOffsetX(value: string | number);
  76294. /**
  76295. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76296. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76297. */
  76298. get linkOffsetXInPixels(): number;
  76299. set linkOffsetXInPixels(value: number);
  76300. /**
  76301. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76302. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76303. */
  76304. get linkOffsetY(): string | number;
  76305. set linkOffsetY(value: string | number);
  76306. /**
  76307. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76308. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76309. */
  76310. get linkOffsetYInPixels(): number;
  76311. set linkOffsetYInPixels(value: number);
  76312. /** Gets the center coordinate on X axis */
  76313. get centerX(): number;
  76314. /** Gets the center coordinate on Y axis */
  76315. get centerY(): number;
  76316. /** Gets or sets if control is Enabled*/
  76317. get isEnabled(): boolean;
  76318. set isEnabled(value: boolean);
  76319. /** Gets or sets background color of control if it's disabled*/
  76320. get disabledColor(): string;
  76321. set disabledColor(value: string);
  76322. /** Gets or sets front color of control if it's disabled*/
  76323. get disabledColorItem(): string;
  76324. set disabledColorItem(value: string);
  76325. /**
  76326. * Creates a new control
  76327. * @param name defines the name of the control
  76328. */
  76329. constructor(
  76330. /** defines the name of the control */
  76331. name?: string | undefined);
  76332. /** @hidden */
  76333. protected _getTypeName(): string;
  76334. /**
  76335. * Gets the first ascendant in the hierarchy of the given type
  76336. * @param className defines the required type
  76337. * @returns the ascendant or null if not found
  76338. */
  76339. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76340. /** @hidden */
  76341. _resetFontCache(): void;
  76342. /**
  76343. * Determines if a container is an ascendant of the current control
  76344. * @param container defines the container to look for
  76345. * @returns true if the container is one of the ascendant of the control
  76346. */
  76347. isAscendant(container: Control): boolean;
  76348. /**
  76349. * Gets coordinates in local control space
  76350. * @param globalCoordinates defines the coordinates to transform
  76351. * @returns the new coordinates in local space
  76352. */
  76353. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76354. /**
  76355. * Gets coordinates in local control space
  76356. * @param globalCoordinates defines the coordinates to transform
  76357. * @param result defines the target vector2 where to store the result
  76358. * @returns the current control
  76359. */
  76360. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76361. /**
  76362. * Gets coordinates in parent local control space
  76363. * @param globalCoordinates defines the coordinates to transform
  76364. * @returns the new coordinates in parent local space
  76365. */
  76366. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76367. /**
  76368. * Move the current control to a vector3 position projected onto the screen.
  76369. * @param position defines the target position
  76370. * @param scene defines the hosting scene
  76371. */
  76372. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76373. /**
  76374. * Will store all controls that have this control as ascendant in a given array
  76375. * @param results defines the array where to store the descendants
  76376. * @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
  76377. * @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
  76378. */
  76379. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76380. /**
  76381. * Will return all controls that have this control as ascendant
  76382. * @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
  76383. * @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
  76384. * @return all child controls
  76385. */
  76386. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76387. /**
  76388. * Link current control with a target mesh
  76389. * @param mesh defines the mesh to link with
  76390. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76391. */
  76392. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76393. /** @hidden */
  76394. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76395. /** @hidden */
  76396. _offsetLeft(offset: number): void;
  76397. /** @hidden */
  76398. _offsetTop(offset: number): void;
  76399. /** @hidden */
  76400. _markMatrixAsDirty(): void;
  76401. /** @hidden */
  76402. _flagDescendantsAsMatrixDirty(): void;
  76403. /** @hidden */
  76404. _intersectsRect(rect: Measure): boolean;
  76405. /** @hidden */
  76406. protected invalidateRect(): void;
  76407. /** @hidden */
  76408. _markAsDirty(force?: boolean): void;
  76409. /** @hidden */
  76410. _markAllAsDirty(): void;
  76411. /** @hidden */
  76412. _link(host: AdvancedDynamicTexture): void;
  76413. /** @hidden */
  76414. protected _transform(context?: CanvasRenderingContext2D): void;
  76415. /** @hidden */
  76416. _renderHighlight(context: CanvasRenderingContext2D): void;
  76417. /** @hidden */
  76418. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76419. /** @hidden */
  76420. protected _applyStates(context: CanvasRenderingContext2D): void;
  76421. /** @hidden */
  76422. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76423. /** @hidden */
  76424. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76425. protected _evaluateClippingState(parentMeasure: Measure): void;
  76426. /** @hidden */
  76427. _measure(): void;
  76428. /** @hidden */
  76429. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76430. /** @hidden */
  76431. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76432. /** @hidden */
  76433. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76434. /** @hidden */
  76435. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76436. private static _ClipMeasure;
  76437. private _tmpMeasureA;
  76438. private _clip;
  76439. /** @hidden */
  76440. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76441. /** @hidden */
  76442. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76443. /**
  76444. * Tests if a given coordinates belong to the current control
  76445. * @param x defines x coordinate to test
  76446. * @param y defines y coordinate to test
  76447. * @returns true if the coordinates are inside the control
  76448. */
  76449. contains(x: number, y: number): boolean;
  76450. /** @hidden */
  76451. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76452. /** @hidden */
  76453. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76454. /** @hidden */
  76455. _onPointerEnter(target: Control): boolean;
  76456. /** @hidden */
  76457. _onPointerOut(target: Control, force?: boolean): void;
  76458. /** @hidden */
  76459. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76460. /** @hidden */
  76461. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76462. /** @hidden */
  76463. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76464. /** @hidden */
  76465. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76466. /** @hidden */
  76467. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76468. private _prepareFont;
  76469. /** Releases associated resources */
  76470. dispose(): void;
  76471. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76472. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76473. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76474. private static _VERTICAL_ALIGNMENT_TOP;
  76475. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76476. private static _VERTICAL_ALIGNMENT_CENTER;
  76477. /** HORIZONTAL_ALIGNMENT_LEFT */
  76478. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76479. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76480. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76481. /** HORIZONTAL_ALIGNMENT_CENTER */
  76482. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76483. /** VERTICAL_ALIGNMENT_TOP */
  76484. static get VERTICAL_ALIGNMENT_TOP(): number;
  76485. /** VERTICAL_ALIGNMENT_BOTTOM */
  76486. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76487. /** VERTICAL_ALIGNMENT_CENTER */
  76488. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76489. private static _FontHeightSizes;
  76490. /** @hidden */
  76491. static _GetFontOffset(font: string): {
  76492. ascent: number;
  76493. height: number;
  76494. descent: number;
  76495. };
  76496. /**
  76497. * Creates a stack panel that can be used to render headers
  76498. * @param control defines the control to associate with the header
  76499. * @param text defines the text of the header
  76500. * @param size defines the size of the header
  76501. * @param options defines options used to configure the header
  76502. * @returns a new StackPanel
  76503. * @ignore
  76504. * @hidden
  76505. */
  76506. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76507. isHorizontal: boolean;
  76508. controlFirst: boolean;
  76509. }) => any;
  76510. /** @hidden */
  76511. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76512. }
  76513. }
  76514. declare module BABYLON.GUI {
  76515. /**
  76516. * Root class for 2D containers
  76517. * @see https://doc.babylonjs.com/how_to/gui#containers
  76518. */
  76519. export class Container extends Control {
  76520. name?: string | undefined;
  76521. /** @hidden */
  76522. _children: Control[];
  76523. /** @hidden */
  76524. protected _measureForChildren: Measure;
  76525. /** @hidden */
  76526. protected _background: string;
  76527. /** @hidden */
  76528. protected _adaptWidthToChildren: boolean;
  76529. /** @hidden */
  76530. protected _adaptHeightToChildren: boolean;
  76531. /**
  76532. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76533. */
  76534. logLayoutCycleErrors: boolean;
  76535. /**
  76536. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76537. */
  76538. maxLayoutCycle: number;
  76539. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76540. get adaptHeightToChildren(): boolean;
  76541. set adaptHeightToChildren(value: boolean);
  76542. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76543. get adaptWidthToChildren(): boolean;
  76544. set adaptWidthToChildren(value: boolean);
  76545. /** Gets or sets background color */
  76546. get background(): string;
  76547. set background(value: string);
  76548. /** Gets the list of children */
  76549. get children(): Control[];
  76550. /**
  76551. * Creates a new Container
  76552. * @param name defines the name of the container
  76553. */
  76554. constructor(name?: string | undefined);
  76555. protected _getTypeName(): string;
  76556. _flagDescendantsAsMatrixDirty(): void;
  76557. /**
  76558. * Gets a child using its name
  76559. * @param name defines the child name to look for
  76560. * @returns the child control if found
  76561. */
  76562. getChildByName(name: string): BABYLON.Nullable<Control>;
  76563. /**
  76564. * Gets a child using its type and its name
  76565. * @param name defines the child name to look for
  76566. * @param type defines the child type to look for
  76567. * @returns the child control if found
  76568. */
  76569. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76570. /**
  76571. * Search for a specific control in children
  76572. * @param control defines the control to look for
  76573. * @returns true if the control is in child list
  76574. */
  76575. containsControl(control: Control): boolean;
  76576. /**
  76577. * Adds a new control to the current container
  76578. * @param control defines the control to add
  76579. * @returns the current container
  76580. */
  76581. addControl(control: BABYLON.Nullable<Control>): Container;
  76582. /**
  76583. * Removes all controls from the current container
  76584. * @returns the current container
  76585. */
  76586. clearControls(): Container;
  76587. /**
  76588. * Removes a control from the current container
  76589. * @param control defines the control to remove
  76590. * @returns the current container
  76591. */
  76592. removeControl(control: Control): Container;
  76593. /** @hidden */
  76594. _reOrderControl(control: Control): void;
  76595. /** @hidden */
  76596. _offsetLeft(offset: number): void;
  76597. /** @hidden */
  76598. _offsetTop(offset: number): void;
  76599. /** @hidden */
  76600. _markAllAsDirty(): void;
  76601. /** @hidden */
  76602. protected _localDraw(context: CanvasRenderingContext2D): void;
  76603. /** @hidden */
  76604. _link(host: AdvancedDynamicTexture): void;
  76605. /** @hidden */
  76606. protected _beforeLayout(): void;
  76607. /** @hidden */
  76608. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76609. /** @hidden */
  76610. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76611. protected _postMeasure(): void;
  76612. /** @hidden */
  76613. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76614. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76615. /** @hidden */
  76616. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76617. /** @hidden */
  76618. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76619. /** Releases associated resources */
  76620. dispose(): void;
  76621. }
  76622. }
  76623. declare module BABYLON.GUI {
  76624. /** Class used to create rectangle container */
  76625. export class Rectangle extends Container {
  76626. name?: string | undefined;
  76627. private _thickness;
  76628. private _cornerRadius;
  76629. /** Gets or sets border thickness */
  76630. get thickness(): number;
  76631. set thickness(value: number);
  76632. /** Gets or sets the corner radius angle */
  76633. get cornerRadius(): number;
  76634. set cornerRadius(value: number);
  76635. /**
  76636. * Creates a new Rectangle
  76637. * @param name defines the control name
  76638. */
  76639. constructor(name?: string | undefined);
  76640. protected _getTypeName(): string;
  76641. protected _localDraw(context: CanvasRenderingContext2D): void;
  76642. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76643. private _drawRoundedRect;
  76644. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76645. }
  76646. }
  76647. declare module BABYLON.GUI {
  76648. /**
  76649. * Enum that determines the text-wrapping mode to use.
  76650. */
  76651. export enum TextWrapping {
  76652. /**
  76653. * Clip the text when it's larger than Control.width; this is the default mode.
  76654. */
  76655. Clip = 0,
  76656. /**
  76657. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76658. */
  76659. WordWrap = 1,
  76660. /**
  76661. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76662. */
  76663. Ellipsis = 2
  76664. }
  76665. /**
  76666. * Class used to create text block control
  76667. */
  76668. export class TextBlock extends Control {
  76669. /**
  76670. * Defines the name of the control
  76671. */
  76672. name?: string | undefined;
  76673. private _text;
  76674. private _textWrapping;
  76675. private _textHorizontalAlignment;
  76676. private _textVerticalAlignment;
  76677. private _lines;
  76678. private _resizeToFit;
  76679. private _lineSpacing;
  76680. private _outlineWidth;
  76681. private _outlineColor;
  76682. /**
  76683. * An event triggered after the text is changed
  76684. */
  76685. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76686. /**
  76687. * An event triggered after the text was broken up into lines
  76688. */
  76689. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76690. /**
  76691. * Function used to split a string into words. By default, a string is split at each space character found
  76692. */
  76693. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76694. /**
  76695. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76696. */
  76697. get lines(): any[];
  76698. /**
  76699. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76700. */
  76701. get resizeToFit(): boolean;
  76702. /**
  76703. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76704. */
  76705. set resizeToFit(value: boolean);
  76706. /**
  76707. * Gets or sets a boolean indicating if text must be wrapped
  76708. */
  76709. get textWrapping(): TextWrapping | boolean;
  76710. /**
  76711. * Gets or sets a boolean indicating if text must be wrapped
  76712. */
  76713. set textWrapping(value: TextWrapping | boolean);
  76714. /**
  76715. * Gets or sets text to display
  76716. */
  76717. get text(): string;
  76718. /**
  76719. * Gets or sets text to display
  76720. */
  76721. set text(value: string);
  76722. /**
  76723. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76724. */
  76725. get textHorizontalAlignment(): number;
  76726. /**
  76727. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76728. */
  76729. set textHorizontalAlignment(value: number);
  76730. /**
  76731. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76732. */
  76733. get textVerticalAlignment(): number;
  76734. /**
  76735. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76736. */
  76737. set textVerticalAlignment(value: number);
  76738. /**
  76739. * Gets or sets line spacing value
  76740. */
  76741. set lineSpacing(value: string | number);
  76742. /**
  76743. * Gets or sets line spacing value
  76744. */
  76745. get lineSpacing(): string | number;
  76746. /**
  76747. * Gets or sets outlineWidth of the text to display
  76748. */
  76749. get outlineWidth(): number;
  76750. /**
  76751. * Gets or sets outlineWidth of the text to display
  76752. */
  76753. set outlineWidth(value: number);
  76754. /**
  76755. * Gets or sets outlineColor of the text to display
  76756. */
  76757. get outlineColor(): string;
  76758. /**
  76759. * Gets or sets outlineColor of the text to display
  76760. */
  76761. set outlineColor(value: string);
  76762. /**
  76763. * Creates a new TextBlock object
  76764. * @param name defines the name of the control
  76765. * @param text defines the text to display (emptry string by default)
  76766. */
  76767. constructor(
  76768. /**
  76769. * Defines the name of the control
  76770. */
  76771. name?: string | undefined, text?: string);
  76772. protected _getTypeName(): string;
  76773. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76774. private _drawText;
  76775. /** @hidden */
  76776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76777. protected _applyStates(context: CanvasRenderingContext2D): void;
  76778. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76779. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76780. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76781. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76782. protected _renderLines(context: CanvasRenderingContext2D): void;
  76783. /**
  76784. * Given a width constraint applied on the text block, find the expected height
  76785. * @returns expected height
  76786. */
  76787. computeExpectedHeight(): number;
  76788. dispose(): void;
  76789. }
  76790. }
  76791. declare module BABYLON.GUI {
  76792. /**
  76793. * Class used to create 2D images
  76794. */
  76795. export class Image extends Control {
  76796. name?: string | undefined;
  76797. private _workingCanvas;
  76798. private _domImage;
  76799. private _imageWidth;
  76800. private _imageHeight;
  76801. private _loaded;
  76802. private _stretch;
  76803. private _source;
  76804. private _autoScale;
  76805. private _sourceLeft;
  76806. private _sourceTop;
  76807. private _sourceWidth;
  76808. private _sourceHeight;
  76809. private _svgAttributesComputationCompleted;
  76810. private _isSVG;
  76811. private _cellWidth;
  76812. private _cellHeight;
  76813. private _cellId;
  76814. private _populateNinePatchSlicesFromImage;
  76815. private _sliceLeft;
  76816. private _sliceRight;
  76817. private _sliceTop;
  76818. private _sliceBottom;
  76819. private _detectPointerOnOpaqueOnly;
  76820. /**
  76821. * BABYLON.Observable notified when the content is loaded
  76822. */
  76823. onImageLoadedObservable: BABYLON.Observable<Image>;
  76824. /**
  76825. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76826. */
  76827. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76828. /**
  76829. * Gets a boolean indicating that the content is loaded
  76830. */
  76831. get isLoaded(): boolean;
  76832. /**
  76833. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76834. */
  76835. get populateNinePatchSlicesFromImage(): boolean;
  76836. set populateNinePatchSlicesFromImage(value: boolean);
  76837. /**
  76838. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76839. * Beware using this as this will comsume more memory as the image has to be stored twice
  76840. */
  76841. get detectPointerOnOpaqueOnly(): boolean;
  76842. set detectPointerOnOpaqueOnly(value: boolean);
  76843. /**
  76844. * Gets or sets the left value for slicing (9-patch)
  76845. */
  76846. get sliceLeft(): number;
  76847. set sliceLeft(value: number);
  76848. /**
  76849. * Gets or sets the right value for slicing (9-patch)
  76850. */
  76851. get sliceRight(): number;
  76852. set sliceRight(value: number);
  76853. /**
  76854. * Gets or sets the top value for slicing (9-patch)
  76855. */
  76856. get sliceTop(): number;
  76857. set sliceTop(value: number);
  76858. /**
  76859. * Gets or sets the bottom value for slicing (9-patch)
  76860. */
  76861. get sliceBottom(): number;
  76862. set sliceBottom(value: number);
  76863. /**
  76864. * Gets or sets the left coordinate in the source image
  76865. */
  76866. get sourceLeft(): number;
  76867. set sourceLeft(value: number);
  76868. /**
  76869. * Gets or sets the top coordinate in the source image
  76870. */
  76871. get sourceTop(): number;
  76872. set sourceTop(value: number);
  76873. /**
  76874. * Gets or sets the width to capture in the source image
  76875. */
  76876. get sourceWidth(): number;
  76877. set sourceWidth(value: number);
  76878. /**
  76879. * Gets or sets the height to capture in the source image
  76880. */
  76881. get sourceHeight(): number;
  76882. set sourceHeight(value: number);
  76883. /** Indicates if the format of the image is SVG */
  76884. get isSVG(): boolean;
  76885. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76886. get svgAttributesComputationCompleted(): boolean;
  76887. /**
  76888. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76889. * @see https://doc.babylonjs.com/how_to/gui#image
  76890. */
  76891. get autoScale(): boolean;
  76892. set autoScale(value: boolean);
  76893. /** Gets or sets the streching mode used by the image */
  76894. get stretch(): number;
  76895. set stretch(value: number);
  76896. /** @hidden */
  76897. _rotate90(n: number, preserveProperties?: boolean): Image;
  76898. private _handleRotationForSVGImage;
  76899. private _rotate90SourceProperties;
  76900. /**
  76901. * Gets or sets the internal DOM image used to render the control
  76902. */
  76903. set domImage(value: HTMLImageElement);
  76904. get domImage(): HTMLImageElement;
  76905. private _onImageLoaded;
  76906. private _extractNinePatchSliceDataFromImage;
  76907. /**
  76908. * Gets or sets image source url
  76909. */
  76910. set source(value: BABYLON.Nullable<string>);
  76911. /**
  76912. * Checks for svg document with icon id present
  76913. */
  76914. private _svgCheck;
  76915. /**
  76916. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76917. * given external svg file and icon id
  76918. */
  76919. private _getSVGAttribs;
  76920. /**
  76921. * Gets or sets the cell width to use when animation sheet is enabled
  76922. * @see https://doc.babylonjs.com/how_to/gui#image
  76923. */
  76924. get cellWidth(): number;
  76925. set cellWidth(value: number);
  76926. /**
  76927. * Gets or sets the cell height to use when animation sheet is enabled
  76928. * @see https://doc.babylonjs.com/how_to/gui#image
  76929. */
  76930. get cellHeight(): number;
  76931. set cellHeight(value: number);
  76932. /**
  76933. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76934. * @see https://doc.babylonjs.com/how_to/gui#image
  76935. */
  76936. get cellId(): number;
  76937. set cellId(value: number);
  76938. /**
  76939. * Creates a new Image
  76940. * @param name defines the control name
  76941. * @param url defines the image url
  76942. */
  76943. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76944. /**
  76945. * Tests if a given coordinates belong to the current control
  76946. * @param x defines x coordinate to test
  76947. * @param y defines y coordinate to test
  76948. * @returns true if the coordinates are inside the control
  76949. */
  76950. contains(x: number, y: number): boolean;
  76951. protected _getTypeName(): string;
  76952. /** Force the control to synchronize with its content */
  76953. synchronizeSizeWithContent(): void;
  76954. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76955. private _prepareWorkingCanvasForOpaqueDetection;
  76956. private _drawImage;
  76957. _draw(context: CanvasRenderingContext2D): void;
  76958. private _renderCornerPatch;
  76959. private _renderNinePatch;
  76960. dispose(): void;
  76961. /** STRETCH_NONE */
  76962. static readonly STRETCH_NONE: number;
  76963. /** STRETCH_FILL */
  76964. static readonly STRETCH_FILL: number;
  76965. /** STRETCH_UNIFORM */
  76966. static readonly STRETCH_UNIFORM: number;
  76967. /** STRETCH_EXTEND */
  76968. static readonly STRETCH_EXTEND: number;
  76969. /** NINE_PATCH */
  76970. static readonly STRETCH_NINE_PATCH: number;
  76971. }
  76972. }
  76973. declare module BABYLON.GUI {
  76974. /**
  76975. * Class used to create 2D buttons
  76976. */
  76977. export class Button extends Rectangle {
  76978. name?: string | undefined;
  76979. /**
  76980. * Function called to generate a pointer enter animation
  76981. */
  76982. pointerEnterAnimation: () => void;
  76983. /**
  76984. * Function called to generate a pointer out animation
  76985. */
  76986. pointerOutAnimation: () => void;
  76987. /**
  76988. * Function called to generate a pointer down animation
  76989. */
  76990. pointerDownAnimation: () => void;
  76991. /**
  76992. * Function called to generate a pointer up animation
  76993. */
  76994. pointerUpAnimation: () => void;
  76995. /**
  76996. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76997. */
  76998. delegatePickingToChildren: boolean;
  76999. private _image;
  77000. /**
  77001. * Returns the image part of the button (if any)
  77002. */
  77003. get image(): BABYLON.Nullable<Image>;
  77004. private _textBlock;
  77005. /**
  77006. * Returns the image part of the button (if any)
  77007. */
  77008. get textBlock(): BABYLON.Nullable<TextBlock>;
  77009. /**
  77010. * Creates a new Button
  77011. * @param name defines the name of the button
  77012. */
  77013. constructor(name?: string | undefined);
  77014. protected _getTypeName(): string;
  77015. /** @hidden */
  77016. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77017. /** @hidden */
  77018. _onPointerEnter(target: Control): boolean;
  77019. /** @hidden */
  77020. _onPointerOut(target: Control, force?: boolean): void;
  77021. /** @hidden */
  77022. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77023. /** @hidden */
  77024. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77025. /**
  77026. * Creates a new button made with an image and a text
  77027. * @param name defines the name of the button
  77028. * @param text defines the text of the button
  77029. * @param imageUrl defines the url of the image
  77030. * @returns a new Button
  77031. */
  77032. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77033. /**
  77034. * Creates a new button made with an image
  77035. * @param name defines the name of the button
  77036. * @param imageUrl defines the url of the image
  77037. * @returns a new Button
  77038. */
  77039. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77040. /**
  77041. * Creates a new button made with a text
  77042. * @param name defines the name of the button
  77043. * @param text defines the text of the button
  77044. * @returns a new Button
  77045. */
  77046. static CreateSimpleButton(name: string, text: string): Button;
  77047. /**
  77048. * Creates a new button made with an image and a centered text
  77049. * @param name defines the name of the button
  77050. * @param text defines the text of the button
  77051. * @param imageUrl defines the url of the image
  77052. * @returns a new Button
  77053. */
  77054. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77055. }
  77056. }
  77057. declare module BABYLON.GUI {
  77058. /**
  77059. * Class used to create a 2D stack panel container
  77060. */
  77061. export class StackPanel extends Container {
  77062. name?: string | undefined;
  77063. private _isVertical;
  77064. private _manualWidth;
  77065. private _manualHeight;
  77066. private _doNotTrackManualChanges;
  77067. /**
  77068. * Gets or sets a boolean indicating that layou warnings should be ignored
  77069. */
  77070. ignoreLayoutWarnings: boolean;
  77071. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77072. get isVertical(): boolean;
  77073. set isVertical(value: boolean);
  77074. /**
  77075. * Gets or sets panel width.
  77076. * This value should not be set when in horizontal mode as it will be computed automatically
  77077. */
  77078. set width(value: string | number);
  77079. get width(): string | number;
  77080. /**
  77081. * Gets or sets panel height.
  77082. * This value should not be set when in vertical mode as it will be computed automatically
  77083. */
  77084. set height(value: string | number);
  77085. get height(): string | number;
  77086. /**
  77087. * Creates a new StackPanel
  77088. * @param name defines control name
  77089. */
  77090. constructor(name?: string | undefined);
  77091. protected _getTypeName(): string;
  77092. /** @hidden */
  77093. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77094. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77095. protected _postMeasure(): void;
  77096. }
  77097. }
  77098. declare module BABYLON.GUI {
  77099. /**
  77100. * Class used to represent a 2D checkbox
  77101. */
  77102. export class Checkbox extends Control {
  77103. name?: string | undefined;
  77104. private _isChecked;
  77105. private _background;
  77106. private _checkSizeRatio;
  77107. private _thickness;
  77108. /** Gets or sets border thickness */
  77109. get thickness(): number;
  77110. set thickness(value: number);
  77111. /**
  77112. * BABYLON.Observable raised when isChecked property changes
  77113. */
  77114. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77115. /** Gets or sets a value indicating the ratio between overall size and check size */
  77116. get checkSizeRatio(): number;
  77117. set checkSizeRatio(value: number);
  77118. /** Gets or sets background color */
  77119. get background(): string;
  77120. set background(value: string);
  77121. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77122. get isChecked(): boolean;
  77123. set isChecked(value: boolean);
  77124. /**
  77125. * Creates a new CheckBox
  77126. * @param name defines the control name
  77127. */
  77128. constructor(name?: string | undefined);
  77129. protected _getTypeName(): string;
  77130. /** @hidden */
  77131. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77132. /** @hidden */
  77133. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77134. /**
  77135. * Utility function to easily create a checkbox with a header
  77136. * @param title defines the label to use for the header
  77137. * @param onValueChanged defines the callback to call when value changes
  77138. * @returns a StackPanel containing the checkbox and a textBlock
  77139. */
  77140. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77141. }
  77142. }
  77143. declare module BABYLON.GUI {
  77144. /**
  77145. * Class used to store key control properties
  77146. */
  77147. export class KeyPropertySet {
  77148. /** Width */
  77149. width?: string;
  77150. /** Height */
  77151. height?: string;
  77152. /** Left padding */
  77153. paddingLeft?: string;
  77154. /** Right padding */
  77155. paddingRight?: string;
  77156. /** Top padding */
  77157. paddingTop?: string;
  77158. /** Bottom padding */
  77159. paddingBottom?: string;
  77160. /** Foreground color */
  77161. color?: string;
  77162. /** Background color */
  77163. background?: string;
  77164. }
  77165. /**
  77166. * Class used to create virtual keyboard
  77167. */
  77168. export class VirtualKeyboard extends StackPanel {
  77169. /** BABYLON.Observable raised when a key is pressed */
  77170. onKeyPressObservable: BABYLON.Observable<string>;
  77171. /** Gets or sets default key button width */
  77172. defaultButtonWidth: string;
  77173. /** Gets or sets default key button height */
  77174. defaultButtonHeight: string;
  77175. /** Gets or sets default key button left padding */
  77176. defaultButtonPaddingLeft: string;
  77177. /** Gets or sets default key button right padding */
  77178. defaultButtonPaddingRight: string;
  77179. /** Gets or sets default key button top padding */
  77180. defaultButtonPaddingTop: string;
  77181. /** Gets or sets default key button bottom padding */
  77182. defaultButtonPaddingBottom: string;
  77183. /** Gets or sets default key button foreground color */
  77184. defaultButtonColor: string;
  77185. /** Gets or sets default key button background color */
  77186. defaultButtonBackground: string;
  77187. /** Gets or sets shift button foreground color */
  77188. shiftButtonColor: string;
  77189. /** Gets or sets shift button thickness*/
  77190. selectedShiftThickness: number;
  77191. /** Gets shift key state */
  77192. shiftState: number;
  77193. protected _getTypeName(): string;
  77194. private _createKey;
  77195. /**
  77196. * Adds a new row of keys
  77197. * @param keys defines the list of keys to add
  77198. * @param propertySets defines the associated property sets
  77199. */
  77200. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77201. /**
  77202. * Set the shift key to a specific state
  77203. * @param shiftState defines the new shift state
  77204. */
  77205. applyShiftState(shiftState: number): void;
  77206. private _currentlyConnectedInputText;
  77207. private _connectedInputTexts;
  77208. private _onKeyPressObserver;
  77209. /** Gets the input text control currently attached to the keyboard */
  77210. get connectedInputText(): BABYLON.Nullable<InputText>;
  77211. /**
  77212. * Connects the keyboard with an input text control
  77213. *
  77214. * @param input defines the target control
  77215. */
  77216. connect(input: InputText): void;
  77217. /**
  77218. * Disconnects the keyboard from connected InputText controls
  77219. *
  77220. * @param input optionally defines a target control, otherwise all are disconnected
  77221. */
  77222. disconnect(input?: InputText): void;
  77223. private _removeConnectedInputObservables;
  77224. /**
  77225. * Release all resources
  77226. */
  77227. dispose(): void;
  77228. /**
  77229. * Creates a new keyboard using a default layout
  77230. *
  77231. * @param name defines control name
  77232. * @returns a new VirtualKeyboard
  77233. */
  77234. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77235. }
  77236. }
  77237. declare module BABYLON.GUI {
  77238. /**
  77239. * Class used to create input text control
  77240. */
  77241. export class InputText extends Control implements IFocusableControl {
  77242. name?: string | undefined;
  77243. private _text;
  77244. private _placeholderText;
  77245. private _background;
  77246. private _focusedBackground;
  77247. private _focusedColor;
  77248. private _placeholderColor;
  77249. private _thickness;
  77250. private _margin;
  77251. private _autoStretchWidth;
  77252. private _maxWidth;
  77253. private _isFocused;
  77254. private _blinkTimeout;
  77255. private _blinkIsEven;
  77256. private _cursorOffset;
  77257. private _scrollLeft;
  77258. private _textWidth;
  77259. private _clickedCoordinate;
  77260. private _deadKey;
  77261. private _addKey;
  77262. private _currentKey;
  77263. private _isTextHighlightOn;
  77264. private _textHighlightColor;
  77265. private _highligherOpacity;
  77266. private _highlightedText;
  77267. private _startHighlightIndex;
  77268. private _endHighlightIndex;
  77269. private _cursorIndex;
  77270. private _onFocusSelectAll;
  77271. private _isPointerDown;
  77272. private _onClipboardObserver;
  77273. private _onPointerDblTapObserver;
  77274. /** @hidden */
  77275. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77276. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77277. promptMessage: string;
  77278. /** Force disable prompt on mobile device */
  77279. disableMobilePrompt: boolean;
  77280. /** BABYLON.Observable raised when the text changes */
  77281. onTextChangedObservable: BABYLON.Observable<InputText>;
  77282. /** BABYLON.Observable raised just before an entered character is to be added */
  77283. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77284. /** BABYLON.Observable raised when the control gets the focus */
  77285. onFocusObservable: BABYLON.Observable<InputText>;
  77286. /** BABYLON.Observable raised when the control loses the focus */
  77287. onBlurObservable: BABYLON.Observable<InputText>;
  77288. /**Observable raised when the text is highlighted */
  77289. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77290. /**Observable raised when copy event is triggered */
  77291. onTextCopyObservable: BABYLON.Observable<InputText>;
  77292. /** BABYLON.Observable raised when cut event is triggered */
  77293. onTextCutObservable: BABYLON.Observable<InputText>;
  77294. /** BABYLON.Observable raised when paste event is triggered */
  77295. onTextPasteObservable: BABYLON.Observable<InputText>;
  77296. /** BABYLON.Observable raised when a key event was processed */
  77297. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77298. /** Gets or sets the maximum width allowed by the control */
  77299. get maxWidth(): string | number;
  77300. /** Gets the maximum width allowed by the control in pixels */
  77301. get maxWidthInPixels(): number;
  77302. set maxWidth(value: string | number);
  77303. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77304. get highligherOpacity(): number;
  77305. set highligherOpacity(value: number);
  77306. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77307. get onFocusSelectAll(): boolean;
  77308. set onFocusSelectAll(value: boolean);
  77309. /** Gets or sets the text hightlight color */
  77310. get textHighlightColor(): string;
  77311. set textHighlightColor(value: string);
  77312. /** Gets or sets control margin */
  77313. get margin(): string;
  77314. /** Gets control margin in pixels */
  77315. get marginInPixels(): number;
  77316. set margin(value: string);
  77317. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77318. get autoStretchWidth(): boolean;
  77319. set autoStretchWidth(value: boolean);
  77320. /** Gets or sets border thickness */
  77321. get thickness(): number;
  77322. set thickness(value: number);
  77323. /** Gets or sets the background color when focused */
  77324. get focusedBackground(): string;
  77325. set focusedBackground(value: string);
  77326. /** Gets or sets the background color when focused */
  77327. get focusedColor(): string;
  77328. set focusedColor(value: string);
  77329. /** Gets or sets the background color */
  77330. get background(): string;
  77331. set background(value: string);
  77332. /** Gets or sets the placeholder color */
  77333. get placeholderColor(): string;
  77334. set placeholderColor(value: string);
  77335. /** Gets or sets the text displayed when the control is empty */
  77336. get placeholderText(): string;
  77337. set placeholderText(value: string);
  77338. /** Gets or sets the dead key flag */
  77339. get deadKey(): boolean;
  77340. set deadKey(flag: boolean);
  77341. /** Gets or sets the highlight text */
  77342. get highlightedText(): string;
  77343. set highlightedText(text: string);
  77344. /** Gets or sets if the current key should be added */
  77345. get addKey(): boolean;
  77346. set addKey(flag: boolean);
  77347. /** Gets or sets the value of the current key being entered */
  77348. get currentKey(): string;
  77349. set currentKey(key: string);
  77350. /** Gets or sets the text displayed in the control */
  77351. get text(): string;
  77352. set text(value: string);
  77353. /** Gets or sets control width */
  77354. get width(): string | number;
  77355. set width(value: string | number);
  77356. /**
  77357. * Creates a new InputText
  77358. * @param name defines the control name
  77359. * @param text defines the text of the control
  77360. */
  77361. constructor(name?: string | undefined, text?: string);
  77362. /** @hidden */
  77363. onBlur(): void;
  77364. /** @hidden */
  77365. onFocus(): void;
  77366. protected _getTypeName(): string;
  77367. /**
  77368. * Function called to get the list of controls that should not steal the focus from this control
  77369. * @returns an array of controls
  77370. */
  77371. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77372. /** @hidden */
  77373. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77374. /** @hidden */
  77375. private _updateValueFromCursorIndex;
  77376. /** @hidden */
  77377. private _processDblClick;
  77378. /** @hidden */
  77379. private _selectAllText;
  77380. /**
  77381. * Handles the keyboard event
  77382. * @param evt Defines the KeyboardEvent
  77383. */
  77384. processKeyboard(evt: KeyboardEvent): void;
  77385. /** @hidden */
  77386. private _onCopyText;
  77387. /** @hidden */
  77388. private _onCutText;
  77389. /** @hidden */
  77390. private _onPasteText;
  77391. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77392. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77393. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77394. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77395. protected _beforeRenderText(text: string): string;
  77396. dispose(): void;
  77397. }
  77398. }
  77399. declare module BABYLON.GUI {
  77400. /**
  77401. * Class used to create a 2D grid container
  77402. */
  77403. export class Grid extends Container {
  77404. name?: string | undefined;
  77405. private _rowDefinitions;
  77406. private _columnDefinitions;
  77407. private _cells;
  77408. private _childControls;
  77409. /**
  77410. * Gets the number of columns
  77411. */
  77412. get columnCount(): number;
  77413. /**
  77414. * Gets the number of rows
  77415. */
  77416. get rowCount(): number;
  77417. /** Gets the list of children */
  77418. get children(): Control[];
  77419. /** Gets the list of cells (e.g. the containers) */
  77420. get cells(): {
  77421. [key: string]: Container;
  77422. };
  77423. /**
  77424. * Gets the definition of a specific row
  77425. * @param index defines the index of the row
  77426. * @returns the row definition
  77427. */
  77428. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77429. /**
  77430. * Gets the definition of a specific column
  77431. * @param index defines the index of the column
  77432. * @returns the column definition
  77433. */
  77434. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77435. /**
  77436. * Adds a new row to the grid
  77437. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77438. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77439. * @returns the current grid
  77440. */
  77441. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77442. /**
  77443. * Adds a new column to the grid
  77444. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77445. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77446. * @returns the current grid
  77447. */
  77448. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77449. /**
  77450. * Update a row definition
  77451. * @param index defines the index of the row to update
  77452. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77453. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77454. * @returns the current grid
  77455. */
  77456. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77457. /**
  77458. * Update a column definition
  77459. * @param index defines the index of the column to update
  77460. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77461. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77462. * @returns the current grid
  77463. */
  77464. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77465. /**
  77466. * Gets the list of children stored in a specific cell
  77467. * @param row defines the row to check
  77468. * @param column defines the column to check
  77469. * @returns the list of controls
  77470. */
  77471. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77472. /**
  77473. * Gets a string representing the child cell info (row x column)
  77474. * @param child defines the control to get info from
  77475. * @returns a string containing the child cell info (row x column)
  77476. */
  77477. getChildCellInfo(child: Control): string;
  77478. private _removeCell;
  77479. private _offsetCell;
  77480. /**
  77481. * Remove a column definition at specified index
  77482. * @param index defines the index of the column to remove
  77483. * @returns the current grid
  77484. */
  77485. removeColumnDefinition(index: number): Grid;
  77486. /**
  77487. * Remove a row definition at specified index
  77488. * @param index defines the index of the row to remove
  77489. * @returns the current grid
  77490. */
  77491. removeRowDefinition(index: number): Grid;
  77492. /**
  77493. * Adds a new control to the current grid
  77494. * @param control defines the control to add
  77495. * @param row defines the row where to add the control (0 by default)
  77496. * @param column defines the column where to add the control (0 by default)
  77497. * @returns the current grid
  77498. */
  77499. addControl(control: Control, row?: number, column?: number): Grid;
  77500. /**
  77501. * Removes a control from the current container
  77502. * @param control defines the control to remove
  77503. * @returns the current container
  77504. */
  77505. removeControl(control: Control): Container;
  77506. /**
  77507. * Creates a new Grid
  77508. * @param name defines control name
  77509. */
  77510. constructor(name?: string | undefined);
  77511. protected _getTypeName(): string;
  77512. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77513. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77514. _flagDescendantsAsMatrixDirty(): void;
  77515. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77516. /** Releases associated resources */
  77517. dispose(): void;
  77518. }
  77519. }
  77520. declare module BABYLON.GUI {
  77521. /** Class used to create color pickers */
  77522. export class ColorPicker extends Control {
  77523. name?: string | undefined;
  77524. private static _Epsilon;
  77525. private _colorWheelCanvas;
  77526. private _value;
  77527. private _tmpColor;
  77528. private _pointerStartedOnSquare;
  77529. private _pointerStartedOnWheel;
  77530. private _squareLeft;
  77531. private _squareTop;
  77532. private _squareSize;
  77533. private _h;
  77534. private _s;
  77535. private _v;
  77536. private _lastPointerDownID;
  77537. /**
  77538. * BABYLON.Observable raised when the value changes
  77539. */
  77540. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77541. /** Gets or sets the color of the color picker */
  77542. get value(): BABYLON.Color3;
  77543. set value(value: BABYLON.Color3);
  77544. /**
  77545. * Gets or sets control width
  77546. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77547. */
  77548. get width(): string | number;
  77549. set width(value: string | number);
  77550. /**
  77551. * Gets or sets control height
  77552. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77553. */
  77554. get height(): string | number;
  77555. /** Gets or sets control height */
  77556. set height(value: string | number);
  77557. /** Gets or sets control size */
  77558. get size(): string | number;
  77559. set size(value: string | number);
  77560. /**
  77561. * Creates a new ColorPicker
  77562. * @param name defines the control name
  77563. */
  77564. constructor(name?: string | undefined);
  77565. protected _getTypeName(): string;
  77566. /** @hidden */
  77567. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77568. private _updateSquareProps;
  77569. private _drawGradientSquare;
  77570. private _drawCircle;
  77571. private _createColorWheelCanvas;
  77572. /** @hidden */
  77573. _draw(context: CanvasRenderingContext2D): void;
  77574. private _pointerIsDown;
  77575. private _updateValueFromPointer;
  77576. private _isPointOnSquare;
  77577. private _isPointOnWheel;
  77578. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77579. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77580. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77581. /**
  77582. * This function expands the color picker by creating a color picker dialog with manual
  77583. * color value input and the ability to save colors into an array to be used later in
  77584. * subsequent launches of the dialogue.
  77585. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77586. * @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.
  77587. * @returns picked color as a hex string and the saved colors array as hex strings.
  77588. */
  77589. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77590. pickerWidth?: string;
  77591. pickerHeight?: string;
  77592. headerHeight?: string;
  77593. lastColor?: string;
  77594. swatchLimit?: number;
  77595. numSwatchesPerLine?: number;
  77596. savedColors?: Array<string>;
  77597. }): Promise<{
  77598. savedColors?: string[];
  77599. pickedColor: string;
  77600. }>;
  77601. }
  77602. }
  77603. declare module BABYLON.GUI {
  77604. /** Class used to create 2D ellipse containers */
  77605. export class Ellipse extends Container {
  77606. name?: string | undefined;
  77607. private _thickness;
  77608. /** Gets or sets border thickness */
  77609. get thickness(): number;
  77610. set thickness(value: number);
  77611. /**
  77612. * Creates a new Ellipse
  77613. * @param name defines the control name
  77614. */
  77615. constructor(name?: string | undefined);
  77616. protected _getTypeName(): string;
  77617. protected _localDraw(context: CanvasRenderingContext2D): void;
  77618. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77619. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77620. }
  77621. }
  77622. declare module BABYLON.GUI {
  77623. /**
  77624. * Class used to create a password control
  77625. */
  77626. export class InputPassword extends InputText {
  77627. protected _beforeRenderText(text: string): string;
  77628. }
  77629. }
  77630. declare module BABYLON.GUI {
  77631. /** Class used to render 2D lines */
  77632. export class Line extends Control {
  77633. name?: string | undefined;
  77634. private _lineWidth;
  77635. private _x1;
  77636. private _y1;
  77637. private _x2;
  77638. private _y2;
  77639. private _dash;
  77640. private _connectedControl;
  77641. private _connectedControlDirtyObserver;
  77642. /** Gets or sets the dash pattern */
  77643. get dash(): Array<number>;
  77644. set dash(value: Array<number>);
  77645. /** Gets or sets the control connected with the line end */
  77646. get connectedControl(): Control;
  77647. set connectedControl(value: Control);
  77648. /** Gets or sets start coordinates on X axis */
  77649. get x1(): string | number;
  77650. set x1(value: string | number);
  77651. /** Gets or sets start coordinates on Y axis */
  77652. get y1(): string | number;
  77653. set y1(value: string | number);
  77654. /** Gets or sets end coordinates on X axis */
  77655. get x2(): string | number;
  77656. set x2(value: string | number);
  77657. /** Gets or sets end coordinates on Y axis */
  77658. get y2(): string | number;
  77659. set y2(value: string | number);
  77660. /** Gets or sets line width */
  77661. get lineWidth(): number;
  77662. set lineWidth(value: number);
  77663. /** Gets or sets horizontal alignment */
  77664. set horizontalAlignment(value: number);
  77665. /** Gets or sets vertical alignment */
  77666. set verticalAlignment(value: number);
  77667. private get _effectiveX2();
  77668. private get _effectiveY2();
  77669. /**
  77670. * Creates a new Line
  77671. * @param name defines the control name
  77672. */
  77673. constructor(name?: string | undefined);
  77674. protected _getTypeName(): string;
  77675. _draw(context: CanvasRenderingContext2D): void;
  77676. _measure(): void;
  77677. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77678. /**
  77679. * Move one end of the line given 3D cartesian coordinates.
  77680. * @param position Targeted world position
  77681. * @param scene BABYLON.Scene
  77682. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77683. */
  77684. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77685. /**
  77686. * Move one end of the line to a position in screen absolute space.
  77687. * @param projectedPosition Position in screen absolute space (X, Y)
  77688. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77689. */
  77690. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77691. }
  77692. }
  77693. declare module BABYLON.GUI {
  77694. /**
  77695. * Class used to store a point for a MultiLine object.
  77696. * The point can be pure 2D coordinates, a mesh or a control
  77697. */
  77698. export class MultiLinePoint {
  77699. private _multiLine;
  77700. private _x;
  77701. private _y;
  77702. private _control;
  77703. private _mesh;
  77704. private _controlObserver;
  77705. private _meshObserver;
  77706. /** @hidden */
  77707. _point: BABYLON.Vector2;
  77708. /**
  77709. * Creates a new MultiLinePoint
  77710. * @param multiLine defines the source MultiLine object
  77711. */
  77712. constructor(multiLine: MultiLine);
  77713. /** Gets or sets x coordinate */
  77714. get x(): string | number;
  77715. set x(value: string | number);
  77716. /** Gets or sets y coordinate */
  77717. get y(): string | number;
  77718. set y(value: string | number);
  77719. /** Gets or sets the control associated with this point */
  77720. get control(): BABYLON.Nullable<Control>;
  77721. set control(value: BABYLON.Nullable<Control>);
  77722. /** Gets or sets the mesh associated with this point */
  77723. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77724. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77725. /** Resets links */
  77726. resetLinks(): void;
  77727. /**
  77728. * Gets a translation vector
  77729. * @returns the translation vector
  77730. */
  77731. translate(): BABYLON.Vector2;
  77732. private _translatePoint;
  77733. /** Release associated resources */
  77734. dispose(): void;
  77735. }
  77736. }
  77737. declare module BABYLON.GUI {
  77738. /**
  77739. * Class used to create multi line control
  77740. */
  77741. export class MultiLine extends Control {
  77742. name?: string | undefined;
  77743. private _lineWidth;
  77744. private _dash;
  77745. private _points;
  77746. private _minX;
  77747. private _minY;
  77748. private _maxX;
  77749. private _maxY;
  77750. /**
  77751. * Creates a new MultiLine
  77752. * @param name defines the control name
  77753. */
  77754. constructor(name?: string | undefined);
  77755. /** Gets or sets dash pattern */
  77756. get dash(): Array<number>;
  77757. set dash(value: Array<number>);
  77758. /**
  77759. * Gets point stored at specified index
  77760. * @param index defines the index to look for
  77761. * @returns the requested point if found
  77762. */
  77763. getAt(index: number): MultiLinePoint;
  77764. /** Function called when a point is updated */
  77765. onPointUpdate: () => void;
  77766. /**
  77767. * Adds new points to the point collection
  77768. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77769. * @returns the list of created MultiLinePoint
  77770. */
  77771. add(...items: (AbstractMesh | Control | {
  77772. x: string | number;
  77773. y: string | number;
  77774. })[]): MultiLinePoint[];
  77775. /**
  77776. * Adds a new point to the point collection
  77777. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77778. * @returns the created MultiLinePoint
  77779. */
  77780. push(item?: (AbstractMesh | Control | {
  77781. x: string | number;
  77782. y: string | number;
  77783. })): MultiLinePoint;
  77784. /**
  77785. * Remove a specific value or point from the active point collection
  77786. * @param value defines the value or point to remove
  77787. */
  77788. remove(value: number | MultiLinePoint): void;
  77789. /**
  77790. * Resets this object to initial state (no point)
  77791. */
  77792. reset(): void;
  77793. /**
  77794. * Resets all links
  77795. */
  77796. resetLinks(): void;
  77797. /** Gets or sets line width */
  77798. get lineWidth(): number;
  77799. set lineWidth(value: number);
  77800. set horizontalAlignment(value: number);
  77801. set verticalAlignment(value: number);
  77802. protected _getTypeName(): string;
  77803. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77804. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77805. _measure(): void;
  77806. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77807. dispose(): void;
  77808. }
  77809. }
  77810. declare module BABYLON.GUI {
  77811. /**
  77812. * Class used to create radio button controls
  77813. */
  77814. export class RadioButton extends Control {
  77815. name?: string | undefined;
  77816. private _isChecked;
  77817. private _background;
  77818. private _checkSizeRatio;
  77819. private _thickness;
  77820. /** Gets or sets border thickness */
  77821. get thickness(): number;
  77822. set thickness(value: number);
  77823. /** Gets or sets group name */
  77824. group: string;
  77825. /** BABYLON.Observable raised when isChecked is changed */
  77826. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77827. /** Gets or sets a value indicating the ratio between overall size and check size */
  77828. get checkSizeRatio(): number;
  77829. set checkSizeRatio(value: number);
  77830. /** Gets or sets background color */
  77831. get background(): string;
  77832. set background(value: string);
  77833. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77834. get isChecked(): boolean;
  77835. set isChecked(value: boolean);
  77836. /**
  77837. * Creates a new RadioButton
  77838. * @param name defines the control name
  77839. */
  77840. constructor(name?: string | undefined);
  77841. protected _getTypeName(): string;
  77842. _draw(context: CanvasRenderingContext2D): void;
  77843. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77844. /**
  77845. * Utility function to easily create a radio button with a header
  77846. * @param title defines the label to use for the header
  77847. * @param group defines the group to use for the radio button
  77848. * @param isChecked defines the initial state of the radio button
  77849. * @param onValueChanged defines the callback to call when value changes
  77850. * @returns a StackPanel containing the radio button and a textBlock
  77851. */
  77852. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77853. }
  77854. }
  77855. declare module BABYLON.GUI {
  77856. /**
  77857. * Class used to create slider controls
  77858. */
  77859. export class BaseSlider extends Control {
  77860. name?: string | undefined;
  77861. protected _thumbWidth: ValueAndUnit;
  77862. private _minimum;
  77863. private _maximum;
  77864. private _value;
  77865. private _isVertical;
  77866. protected _barOffset: ValueAndUnit;
  77867. private _isThumbClamped;
  77868. protected _displayThumb: boolean;
  77869. private _step;
  77870. private _lastPointerDownID;
  77871. protected _effectiveBarOffset: number;
  77872. protected _renderLeft: number;
  77873. protected _renderTop: number;
  77874. protected _renderWidth: number;
  77875. protected _renderHeight: number;
  77876. protected _backgroundBoxLength: number;
  77877. protected _backgroundBoxThickness: number;
  77878. protected _effectiveThumbThickness: number;
  77879. /** BABYLON.Observable raised when the sldier value changes */
  77880. onValueChangedObservable: BABYLON.Observable<number>;
  77881. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77882. get displayThumb(): boolean;
  77883. set displayThumb(value: boolean);
  77884. /** Gets or sets a step to apply to values (0 by default) */
  77885. get step(): number;
  77886. set step(value: number);
  77887. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77888. get barOffset(): string | number;
  77889. /** Gets main bar offset in pixels*/
  77890. get barOffsetInPixels(): number;
  77891. set barOffset(value: string | number);
  77892. /** Gets or sets thumb width */
  77893. get thumbWidth(): string | number;
  77894. /** Gets thumb width in pixels */
  77895. get thumbWidthInPixels(): number;
  77896. set thumbWidth(value: string | number);
  77897. /** Gets or sets minimum value */
  77898. get minimum(): number;
  77899. set minimum(value: number);
  77900. /** Gets or sets maximum value */
  77901. get maximum(): number;
  77902. set maximum(value: number);
  77903. /** Gets or sets current value */
  77904. get value(): number;
  77905. set value(value: number);
  77906. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77907. get isVertical(): boolean;
  77908. set isVertical(value: boolean);
  77909. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77910. get isThumbClamped(): boolean;
  77911. set isThumbClamped(value: boolean);
  77912. /**
  77913. * Creates a new BaseSlider
  77914. * @param name defines the control name
  77915. */
  77916. constructor(name?: string | undefined);
  77917. protected _getTypeName(): string;
  77918. protected _getThumbPosition(): number;
  77919. protected _getThumbThickness(type: string): number;
  77920. protected _prepareRenderingData(type: string): void;
  77921. private _pointerIsDown;
  77922. /** @hidden */
  77923. protected _updateValueFromPointer(x: number, y: number): void;
  77924. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77925. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77926. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77927. }
  77928. }
  77929. declare module BABYLON.GUI {
  77930. /**
  77931. * Class used to create slider controls
  77932. */
  77933. export class Slider extends BaseSlider {
  77934. name?: string | undefined;
  77935. private _background;
  77936. private _borderColor;
  77937. private _isThumbCircle;
  77938. protected _displayValueBar: boolean;
  77939. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77940. get displayValueBar(): boolean;
  77941. set displayValueBar(value: boolean);
  77942. /** Gets or sets border color */
  77943. get borderColor(): string;
  77944. set borderColor(value: string);
  77945. /** Gets or sets background color */
  77946. get background(): string;
  77947. set background(value: string);
  77948. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77949. get isThumbCircle(): boolean;
  77950. set isThumbCircle(value: boolean);
  77951. /**
  77952. * Creates a new Slider
  77953. * @param name defines the control name
  77954. */
  77955. constructor(name?: string | undefined);
  77956. protected _getTypeName(): string;
  77957. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77958. }
  77959. }
  77960. declare module BABYLON.GUI {
  77961. /** Class used to create a RadioGroup
  77962. * which contains groups of radio buttons
  77963. */
  77964. export class SelectorGroup {
  77965. /** name of SelectorGroup */
  77966. name: string;
  77967. private _groupPanel;
  77968. private _selectors;
  77969. private _groupHeader;
  77970. /**
  77971. * Creates a new SelectorGroup
  77972. * @param name of group, used as a group heading
  77973. */
  77974. constructor(
  77975. /** name of SelectorGroup */
  77976. name: string);
  77977. /** Gets the groupPanel of the SelectorGroup */
  77978. get groupPanel(): StackPanel;
  77979. /** Gets the selectors array */
  77980. get selectors(): StackPanel[];
  77981. /** Gets and sets the group header */
  77982. get header(): string;
  77983. set header(label: string);
  77984. /** @hidden */
  77985. private _addGroupHeader;
  77986. /** @hidden*/
  77987. _getSelector(selectorNb: number): StackPanel | undefined;
  77988. /** Removes the selector at the given position
  77989. * @param selectorNb the position of the selector within the group
  77990. */
  77991. removeSelector(selectorNb: number): void;
  77992. }
  77993. /** Class used to create a CheckboxGroup
  77994. * which contains groups of checkbox buttons
  77995. */
  77996. export class CheckboxGroup extends SelectorGroup {
  77997. /** Adds a checkbox as a control
  77998. * @param text is the label for the selector
  77999. * @param func is the function called when the Selector is checked
  78000. * @param checked is true when Selector is checked
  78001. */
  78002. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78003. /** @hidden */
  78004. _setSelectorLabel(selectorNb: number, label: string): void;
  78005. /** @hidden */
  78006. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78007. /** @hidden */
  78008. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78009. /** @hidden */
  78010. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78011. }
  78012. /** Class used to create a RadioGroup
  78013. * which contains groups of radio buttons
  78014. */
  78015. export class RadioGroup extends SelectorGroup {
  78016. private _selectNb;
  78017. /** Adds a radio button as a control
  78018. * @param label is the label for the selector
  78019. * @param func is the function called when the Selector is checked
  78020. * @param checked is true when Selector is checked
  78021. */
  78022. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78023. /** @hidden */
  78024. _setSelectorLabel(selectorNb: number, label: string): void;
  78025. /** @hidden */
  78026. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78027. /** @hidden */
  78028. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78029. /** @hidden */
  78030. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78031. }
  78032. /** Class used to create a SliderGroup
  78033. * which contains groups of slider buttons
  78034. */
  78035. export class SliderGroup extends SelectorGroup {
  78036. /**
  78037. * Adds a slider to the SelectorGroup
  78038. * @param label is the label for the SliderBar
  78039. * @param func is the function called when the Slider moves
  78040. * @param unit is a string describing the units used, eg degrees or metres
  78041. * @param min is the minimum value for the Slider
  78042. * @param max is the maximum value for the Slider
  78043. * @param value is the start value for the Slider between min and max
  78044. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78045. */
  78046. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78047. /** @hidden */
  78048. _setSelectorLabel(selectorNb: number, label: string): void;
  78049. /** @hidden */
  78050. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78051. /** @hidden */
  78052. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78053. /** @hidden */
  78054. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78055. }
  78056. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78057. * @see https://doc.babylonjs.com/how_to/selector
  78058. */
  78059. export class SelectionPanel extends Rectangle {
  78060. /** name of SelectionPanel */
  78061. name: string;
  78062. /** an array of SelectionGroups */
  78063. groups: SelectorGroup[];
  78064. private _panel;
  78065. private _buttonColor;
  78066. private _buttonBackground;
  78067. private _headerColor;
  78068. private _barColor;
  78069. private _barHeight;
  78070. private _spacerHeight;
  78071. private _labelColor;
  78072. private _groups;
  78073. private _bars;
  78074. /**
  78075. * Creates a new SelectionPanel
  78076. * @param name of SelectionPanel
  78077. * @param groups is an array of SelectionGroups
  78078. */
  78079. constructor(
  78080. /** name of SelectionPanel */
  78081. name: string,
  78082. /** an array of SelectionGroups */
  78083. groups?: SelectorGroup[]);
  78084. protected _getTypeName(): string;
  78085. /** Gets or sets the headerColor */
  78086. get headerColor(): string;
  78087. set headerColor(color: string);
  78088. private _setHeaderColor;
  78089. /** Gets or sets the button color */
  78090. get buttonColor(): string;
  78091. set buttonColor(color: string);
  78092. private _setbuttonColor;
  78093. /** Gets or sets the label color */
  78094. get labelColor(): string;
  78095. set labelColor(color: string);
  78096. private _setLabelColor;
  78097. /** Gets or sets the button background */
  78098. get buttonBackground(): string;
  78099. set buttonBackground(color: string);
  78100. private _setButtonBackground;
  78101. /** Gets or sets the color of separator bar */
  78102. get barColor(): string;
  78103. set barColor(color: string);
  78104. private _setBarColor;
  78105. /** Gets or sets the height of separator bar */
  78106. get barHeight(): string;
  78107. set barHeight(value: string);
  78108. private _setBarHeight;
  78109. /** Gets or sets the height of spacers*/
  78110. get spacerHeight(): string;
  78111. set spacerHeight(value: string);
  78112. private _setSpacerHeight;
  78113. /** Adds a bar between groups */
  78114. private _addSpacer;
  78115. /** Add a group to the selection panel
  78116. * @param group is the selector group to add
  78117. */
  78118. addGroup(group: SelectorGroup): void;
  78119. /** Remove the group from the given position
  78120. * @param groupNb is the position of the group in the list
  78121. */
  78122. removeGroup(groupNb: number): void;
  78123. /** Change a group header label
  78124. * @param label is the new group header label
  78125. * @param groupNb is the number of the group to relabel
  78126. * */
  78127. setHeaderName(label: string, groupNb: number): void;
  78128. /** Change selector label to the one given
  78129. * @param label is the new selector label
  78130. * @param groupNb is the number of the groupcontaining the selector
  78131. * @param selectorNb is the number of the selector within a group to relabel
  78132. * */
  78133. relabel(label: string, groupNb: number, selectorNb: number): void;
  78134. /** For a given group position remove the selector at the given position
  78135. * @param groupNb is the number of the group to remove the selector from
  78136. * @param selectorNb is the number of the selector within the group
  78137. */
  78138. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78139. /** For a given group position of correct type add a checkbox button
  78140. * @param groupNb is the number of the group to remove the selector from
  78141. * @param label is the label for the selector
  78142. * @param func is the function called when the Selector is checked
  78143. * @param checked is true when Selector is checked
  78144. */
  78145. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78146. /** For a given group position of correct type add a radio button
  78147. * @param groupNb is the number of the group to remove the selector from
  78148. * @param label is the label for the selector
  78149. * @param func is the function called when the Selector is checked
  78150. * @param checked is true when Selector is checked
  78151. */
  78152. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78153. /**
  78154. * For a given slider group add a slider
  78155. * @param groupNb is the number of the group to add the slider to
  78156. * @param label is the label for the Slider
  78157. * @param func is the function called when the Slider moves
  78158. * @param unit is a string describing the units used, eg degrees or metres
  78159. * @param min is the minimum value for the Slider
  78160. * @param max is the maximum value for the Slider
  78161. * @param value is the start value for the Slider between min and max
  78162. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78163. */
  78164. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78165. }
  78166. }
  78167. declare module BABYLON.GUI {
  78168. /**
  78169. * Class used to hold a the container for ScrollViewer
  78170. * @hidden
  78171. */
  78172. export class _ScrollViewerWindow extends Container {
  78173. parentClientWidth: number;
  78174. parentClientHeight: number;
  78175. private _freezeControls;
  78176. private _parentMeasure;
  78177. private _oldLeft;
  78178. private _oldTop;
  78179. get freezeControls(): boolean;
  78180. set freezeControls(value: boolean);
  78181. private _bucketWidth;
  78182. private _bucketHeight;
  78183. private _buckets;
  78184. private _bucketLen;
  78185. get bucketWidth(): number;
  78186. get bucketHeight(): number;
  78187. setBucketSizes(width: number, height: number): void;
  78188. private _useBuckets;
  78189. private _makeBuckets;
  78190. private _dispatchInBuckets;
  78191. private _updateMeasures;
  78192. private _updateChildrenMeasures;
  78193. private _restoreMeasures;
  78194. /**
  78195. * Creates a new ScrollViewerWindow
  78196. * @param name of ScrollViewerWindow
  78197. */
  78198. constructor(name?: string);
  78199. protected _getTypeName(): string;
  78200. /** @hidden */
  78201. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78202. /** @hidden */
  78203. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78204. private _scrollChildren;
  78205. private _scrollChildrenWithBuckets;
  78206. /** @hidden */
  78207. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78208. protected _postMeasure(): void;
  78209. }
  78210. }
  78211. declare module BABYLON.GUI {
  78212. /**
  78213. * Class used to create slider controls
  78214. */
  78215. export class ScrollBar extends BaseSlider {
  78216. name?: string | undefined;
  78217. private _background;
  78218. private _borderColor;
  78219. private _tempMeasure;
  78220. /** Gets or sets border color */
  78221. get borderColor(): string;
  78222. set borderColor(value: string);
  78223. /** Gets or sets background color */
  78224. get background(): string;
  78225. set background(value: string);
  78226. /**
  78227. * Creates a new Slider
  78228. * @param name defines the control name
  78229. */
  78230. constructor(name?: string | undefined);
  78231. protected _getTypeName(): string;
  78232. protected _getThumbThickness(): number;
  78233. _draw(context: CanvasRenderingContext2D): void;
  78234. private _first;
  78235. private _originX;
  78236. private _originY;
  78237. /** @hidden */
  78238. protected _updateValueFromPointer(x: number, y: number): void;
  78239. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78240. }
  78241. }
  78242. declare module BABYLON.GUI {
  78243. /**
  78244. * Class used to create slider controls
  78245. */
  78246. export class ImageScrollBar extends BaseSlider {
  78247. name?: string | undefined;
  78248. private _backgroundBaseImage;
  78249. private _backgroundImage;
  78250. private _thumbImage;
  78251. private _thumbBaseImage;
  78252. private _thumbLength;
  78253. private _thumbHeight;
  78254. private _barImageHeight;
  78255. private _tempMeasure;
  78256. /** Number of 90° rotation to apply on the images when in vertical mode */
  78257. num90RotationInVerticalMode: number;
  78258. /**
  78259. * Gets or sets the image used to render the background for horizontal bar
  78260. */
  78261. get backgroundImage(): Image;
  78262. set backgroundImage(value: Image);
  78263. /**
  78264. * Gets or sets the image used to render the thumb
  78265. */
  78266. get thumbImage(): Image;
  78267. set thumbImage(value: Image);
  78268. /**
  78269. * Gets or sets the length of the thumb
  78270. */
  78271. get thumbLength(): number;
  78272. set thumbLength(value: number);
  78273. /**
  78274. * Gets or sets the height of the thumb
  78275. */
  78276. get thumbHeight(): number;
  78277. set thumbHeight(value: number);
  78278. /**
  78279. * Gets or sets the height of the bar image
  78280. */
  78281. get barImageHeight(): number;
  78282. set barImageHeight(value: number);
  78283. /**
  78284. * Creates a new ImageScrollBar
  78285. * @param name defines the control name
  78286. */
  78287. constructor(name?: string | undefined);
  78288. protected _getTypeName(): string;
  78289. protected _getThumbThickness(): number;
  78290. _draw(context: CanvasRenderingContext2D): void;
  78291. private _first;
  78292. private _originX;
  78293. private _originY;
  78294. /** @hidden */
  78295. protected _updateValueFromPointer(x: number, y: number): void;
  78296. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78297. }
  78298. }
  78299. declare module BABYLON.GUI {
  78300. /**
  78301. * Class used to hold a viewer window and sliders in a grid
  78302. */
  78303. export class ScrollViewer extends Rectangle {
  78304. private _grid;
  78305. private _horizontalBarSpace;
  78306. private _verticalBarSpace;
  78307. private _dragSpace;
  78308. private _horizontalBar;
  78309. private _verticalBar;
  78310. private _barColor;
  78311. private _barBackground;
  78312. private _barImage;
  78313. private _horizontalBarImage;
  78314. private _verticalBarImage;
  78315. private _barBackgroundImage;
  78316. private _horizontalBarBackgroundImage;
  78317. private _verticalBarBackgroundImage;
  78318. private _barSize;
  78319. private _window;
  78320. private _pointerIsOver;
  78321. private _wheelPrecision;
  78322. private _onWheelObserver;
  78323. private _clientWidth;
  78324. private _clientHeight;
  78325. private _useImageBar;
  78326. private _thumbLength;
  78327. private _thumbHeight;
  78328. private _barImageHeight;
  78329. private _horizontalBarImageHeight;
  78330. private _verticalBarImageHeight;
  78331. private _oldWindowContentsWidth;
  78332. private _oldWindowContentsHeight;
  78333. /**
  78334. * Gets the horizontal scrollbar
  78335. */
  78336. get horizontalBar(): ScrollBar | ImageScrollBar;
  78337. /**
  78338. * Gets the vertical scrollbar
  78339. */
  78340. get verticalBar(): ScrollBar | ImageScrollBar;
  78341. /**
  78342. * Adds a new control to the current container
  78343. * @param control defines the control to add
  78344. * @returns the current container
  78345. */
  78346. addControl(control: BABYLON.Nullable<Control>): Container;
  78347. /**
  78348. * Removes a control from the current container
  78349. * @param control defines the control to remove
  78350. * @returns the current container
  78351. */
  78352. removeControl(control: Control): Container;
  78353. /** Gets the list of children */
  78354. get children(): Control[];
  78355. _flagDescendantsAsMatrixDirty(): void;
  78356. /**
  78357. * Freezes or unfreezes the controls in the window.
  78358. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78359. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78360. */
  78361. get freezeControls(): boolean;
  78362. set freezeControls(value: boolean);
  78363. /** Gets the bucket width */
  78364. get bucketWidth(): number;
  78365. /** Gets the bucket height */
  78366. get bucketHeight(): number;
  78367. /**
  78368. * Sets the bucket sizes.
  78369. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78370. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78371. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78372. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78373. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78374. * used), that's why it is not enabled by default.
  78375. * @param width width of the bucket
  78376. * @param height height of the bucket
  78377. */
  78378. setBucketSizes(width: number, height: number): void;
  78379. private _forceHorizontalBar;
  78380. private _forceVerticalBar;
  78381. /**
  78382. * Forces the horizontal scroll bar to be displayed
  78383. */
  78384. get forceHorizontalBar(): boolean;
  78385. set forceHorizontalBar(value: boolean);
  78386. /**
  78387. * Forces the vertical scroll bar to be displayed
  78388. */
  78389. get forceVerticalBar(): boolean;
  78390. set forceVerticalBar(value: boolean);
  78391. /**
  78392. * Creates a new ScrollViewer
  78393. * @param name of ScrollViewer
  78394. */
  78395. constructor(name?: string, isImageBased?: boolean);
  78396. /** Reset the scroll viewer window to initial size */
  78397. resetWindow(): void;
  78398. protected _getTypeName(): string;
  78399. private _buildClientSizes;
  78400. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78401. protected _postMeasure(): void;
  78402. /**
  78403. * Gets or sets the mouse wheel precision
  78404. * from 0 to 1 with a default value of 0.05
  78405. * */
  78406. get wheelPrecision(): number;
  78407. set wheelPrecision(value: number);
  78408. /** Gets or sets the scroll bar container background color */
  78409. get scrollBackground(): string;
  78410. set scrollBackground(color: string);
  78411. /** Gets or sets the bar color */
  78412. get barColor(): string;
  78413. set barColor(color: string);
  78414. /** Gets or sets the bar image */
  78415. get thumbImage(): Image;
  78416. set thumbImage(value: Image);
  78417. /** Gets or sets the horizontal bar image */
  78418. get horizontalThumbImage(): Image;
  78419. set horizontalThumbImage(value: Image);
  78420. /** Gets or sets the vertical bar image */
  78421. get verticalThumbImage(): Image;
  78422. set verticalThumbImage(value: Image);
  78423. /** Gets or sets the size of the bar */
  78424. get barSize(): number;
  78425. set barSize(value: number);
  78426. /** Gets or sets the length of the thumb */
  78427. get thumbLength(): number;
  78428. set thumbLength(value: number);
  78429. /** Gets or sets the height of the thumb */
  78430. get thumbHeight(): number;
  78431. set thumbHeight(value: number);
  78432. /** Gets or sets the height of the bar image */
  78433. get barImageHeight(): number;
  78434. set barImageHeight(value: number);
  78435. /** Gets or sets the height of the horizontal bar image */
  78436. get horizontalBarImageHeight(): number;
  78437. set horizontalBarImageHeight(value: number);
  78438. /** Gets or sets the height of the vertical bar image */
  78439. get verticalBarImageHeight(): number;
  78440. set verticalBarImageHeight(value: number);
  78441. /** Gets or sets the bar background */
  78442. get barBackground(): string;
  78443. set barBackground(color: string);
  78444. /** Gets or sets the bar background image */
  78445. get barImage(): Image;
  78446. set barImage(value: Image);
  78447. /** Gets or sets the horizontal bar background image */
  78448. get horizontalBarImage(): Image;
  78449. set horizontalBarImage(value: Image);
  78450. /** Gets or sets the vertical bar background image */
  78451. get verticalBarImage(): Image;
  78452. set verticalBarImage(value: Image);
  78453. private _setWindowPosition;
  78454. /** @hidden */
  78455. private _updateScroller;
  78456. _link(host: AdvancedDynamicTexture): void;
  78457. /** @hidden */
  78458. private _addBar;
  78459. /** @hidden */
  78460. private _attachWheel;
  78461. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78462. /** Releases associated resources */
  78463. dispose(): void;
  78464. }
  78465. }
  78466. declare module BABYLON.GUI {
  78467. /** Class used to render a grid */
  78468. export class DisplayGrid extends Control {
  78469. name?: string | undefined;
  78470. private _cellWidth;
  78471. private _cellHeight;
  78472. private _minorLineTickness;
  78473. private _minorLineColor;
  78474. private _majorLineTickness;
  78475. private _majorLineColor;
  78476. private _majorLineFrequency;
  78477. private _background;
  78478. private _displayMajorLines;
  78479. private _displayMinorLines;
  78480. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78481. get displayMinorLines(): boolean;
  78482. set displayMinorLines(value: boolean);
  78483. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78484. get displayMajorLines(): boolean;
  78485. set displayMajorLines(value: boolean);
  78486. /** Gets or sets background color (Black by default) */
  78487. get background(): string;
  78488. set background(value: string);
  78489. /** Gets or sets the width of each cell (20 by default) */
  78490. get cellWidth(): number;
  78491. set cellWidth(value: number);
  78492. /** Gets or sets the height of each cell (20 by default) */
  78493. get cellHeight(): number;
  78494. set cellHeight(value: number);
  78495. /** Gets or sets the tickness of minor lines (1 by default) */
  78496. get minorLineTickness(): number;
  78497. set minorLineTickness(value: number);
  78498. /** Gets or sets the color of minor lines (DarkGray by default) */
  78499. get minorLineColor(): string;
  78500. set minorLineColor(value: string);
  78501. /** Gets or sets the tickness of major lines (2 by default) */
  78502. get majorLineTickness(): number;
  78503. set majorLineTickness(value: number);
  78504. /** Gets or sets the color of major lines (White by default) */
  78505. get majorLineColor(): string;
  78506. set majorLineColor(value: string);
  78507. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78508. get majorLineFrequency(): number;
  78509. set majorLineFrequency(value: number);
  78510. /**
  78511. * Creates a new GridDisplayRectangle
  78512. * @param name defines the control name
  78513. */
  78514. constructor(name?: string | undefined);
  78515. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78516. protected _getTypeName(): string;
  78517. }
  78518. }
  78519. declare module BABYLON.GUI {
  78520. /**
  78521. * Class used to create slider controls based on images
  78522. */
  78523. export class ImageBasedSlider extends BaseSlider {
  78524. name?: string | undefined;
  78525. private _backgroundImage;
  78526. private _thumbImage;
  78527. private _valueBarImage;
  78528. private _tempMeasure;
  78529. get displayThumb(): boolean;
  78530. set displayThumb(value: boolean);
  78531. /**
  78532. * Gets or sets the image used to render the background
  78533. */
  78534. get backgroundImage(): Image;
  78535. set backgroundImage(value: Image);
  78536. /**
  78537. * Gets or sets the image used to render the value bar
  78538. */
  78539. get valueBarImage(): Image;
  78540. set valueBarImage(value: Image);
  78541. /**
  78542. * Gets or sets the image used to render the thumb
  78543. */
  78544. get thumbImage(): Image;
  78545. set thumbImage(value: Image);
  78546. /**
  78547. * Creates a new ImageBasedSlider
  78548. * @param name defines the control name
  78549. */
  78550. constructor(name?: string | undefined);
  78551. protected _getTypeName(): string;
  78552. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78553. }
  78554. }
  78555. declare module BABYLON.GUI {
  78556. /**
  78557. * Forcing an export so that this code will execute
  78558. * @hidden
  78559. */
  78560. const name = "Statics";
  78561. }
  78562. declare module BABYLON.GUI {
  78563. /**
  78564. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78565. */
  78566. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78567. /**
  78568. * Define the instrumented AdvancedDynamicTexture.
  78569. */
  78570. texture: AdvancedDynamicTexture;
  78571. private _captureRenderTime;
  78572. private _renderTime;
  78573. private _captureLayoutTime;
  78574. private _layoutTime;
  78575. private _onBeginRenderObserver;
  78576. private _onEndRenderObserver;
  78577. private _onBeginLayoutObserver;
  78578. private _onEndLayoutObserver;
  78579. /**
  78580. * Gets the perf counter used to capture render time
  78581. */
  78582. get renderTimeCounter(): BABYLON.PerfCounter;
  78583. /**
  78584. * Gets the perf counter used to capture layout time
  78585. */
  78586. get layoutTimeCounter(): BABYLON.PerfCounter;
  78587. /**
  78588. * Enable or disable the render time capture
  78589. */
  78590. get captureRenderTime(): boolean;
  78591. set captureRenderTime(value: boolean);
  78592. /**
  78593. * Enable or disable the layout time capture
  78594. */
  78595. get captureLayoutTime(): boolean;
  78596. set captureLayoutTime(value: boolean);
  78597. /**
  78598. * Instantiates a new advanced dynamic texture instrumentation.
  78599. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78600. * @param texture Defines the AdvancedDynamicTexture to instrument
  78601. */
  78602. constructor(
  78603. /**
  78604. * Define the instrumented AdvancedDynamicTexture.
  78605. */
  78606. texture: AdvancedDynamicTexture);
  78607. /**
  78608. * Dispose and release associated resources.
  78609. */
  78610. dispose(): void;
  78611. }
  78612. }
  78613. declare module BABYLON.GUI {
  78614. /**
  78615. * Class used to load GUI via XML.
  78616. */
  78617. export class XmlLoader {
  78618. private _nodes;
  78619. private _nodeTypes;
  78620. private _isLoaded;
  78621. private _objectAttributes;
  78622. private _parentClass;
  78623. /**
  78624. * Create a new xml loader
  78625. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78626. */
  78627. constructor(parentClass?: null);
  78628. private _getChainElement;
  78629. private _getClassAttribute;
  78630. private _createGuiElement;
  78631. private _parseGrid;
  78632. private _parseElement;
  78633. private _prepareSourceElement;
  78634. private _parseElementsFromSource;
  78635. private _parseXml;
  78636. /**
  78637. * Gets if the loading has finished.
  78638. * @returns whether the loading has finished or not
  78639. */
  78640. isLoaded(): boolean;
  78641. /**
  78642. * Gets a loaded node / control by id.
  78643. * @param id the Controls id set in the xml
  78644. * @returns element of type Control
  78645. */
  78646. getNodeById(id: string): any;
  78647. /**
  78648. * Gets all loaded nodes / controls
  78649. * @returns Array of controls
  78650. */
  78651. getNodes(): any;
  78652. /**
  78653. * Initiates the xml layout loading
  78654. * @param xmlFile defines the xml layout to load
  78655. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78656. * @param callback defines the callback called on layout load.
  78657. */
  78658. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78659. }
  78660. }
  78661. declare module BABYLON.GUI {
  78662. /**
  78663. * Class used to create containers for controls
  78664. */
  78665. export class Container3D extends Control3D {
  78666. private _blockLayout;
  78667. /**
  78668. * Gets the list of child controls
  78669. */
  78670. protected _children: Control3D[];
  78671. /**
  78672. * Gets the list of child controls
  78673. */
  78674. get children(): Array<Control3D>;
  78675. /**
  78676. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78677. * This is helpful to optimize layout operation when adding multiple children in a row
  78678. */
  78679. get blockLayout(): boolean;
  78680. set blockLayout(value: boolean);
  78681. /**
  78682. * Creates a new container
  78683. * @param name defines the container name
  78684. */
  78685. constructor(name?: string);
  78686. /**
  78687. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78688. * @returns the current container
  78689. */
  78690. updateLayout(): Container3D;
  78691. /**
  78692. * Gets a boolean indicating if the given control is in the children of this control
  78693. * @param control defines the control to check
  78694. * @returns true if the control is in the child list
  78695. */
  78696. containsControl(control: Control3D): boolean;
  78697. /**
  78698. * Adds a control to the children of this control
  78699. * @param control defines the control to add
  78700. * @returns the current container
  78701. */
  78702. addControl(control: Control3D): Container3D;
  78703. /**
  78704. * This function will be called everytime a new control is added
  78705. */
  78706. protected _arrangeChildren(): void;
  78707. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78708. /**
  78709. * Removes a control from the children of this control
  78710. * @param control defines the control to remove
  78711. * @returns the current container
  78712. */
  78713. removeControl(control: Control3D): Container3D;
  78714. protected _getTypeName(): string;
  78715. /**
  78716. * Releases all associated resources
  78717. */
  78718. dispose(): void;
  78719. /** Control rotation will remain unchanged */
  78720. static readonly UNSET_ORIENTATION: number;
  78721. /** Control will rotate to make it look at sphere central axis */
  78722. static readonly FACEORIGIN_ORIENTATION: number;
  78723. /** Control will rotate to make it look back at sphere central axis */
  78724. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78725. /** Control will rotate to look at z axis (0, 0, 1) */
  78726. static readonly FACEFORWARD_ORIENTATION: number;
  78727. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78728. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78729. }
  78730. }
  78731. declare module BABYLON.GUI {
  78732. /**
  78733. * Class used to manage 3D user interface
  78734. * @see https://doc.babylonjs.com/how_to/gui3d
  78735. */
  78736. export class GUI3DManager implements BABYLON.IDisposable {
  78737. private _scene;
  78738. private _sceneDisposeObserver;
  78739. private _utilityLayer;
  78740. private _rootContainer;
  78741. private _pointerObserver;
  78742. private _pointerOutObserver;
  78743. /** @hidden */
  78744. _lastPickedControl: Control3D;
  78745. /** @hidden */
  78746. _lastControlOver: {
  78747. [pointerId: number]: Control3D;
  78748. };
  78749. /** @hidden */
  78750. _lastControlDown: {
  78751. [pointerId: number]: Control3D;
  78752. };
  78753. /**
  78754. * BABYLON.Observable raised when the point picked by the pointer events changed
  78755. */
  78756. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78757. /** @hidden */
  78758. _sharedMaterials: {
  78759. [key: string]: BABYLON.Material;
  78760. };
  78761. /** Gets the hosting scene */
  78762. get scene(): BABYLON.Scene;
  78763. /** Gets associated utility layer */
  78764. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78765. /**
  78766. * Creates a new GUI3DManager
  78767. * @param scene
  78768. */
  78769. constructor(scene?: BABYLON.Scene);
  78770. private _handlePointerOut;
  78771. private _doPicking;
  78772. /**
  78773. * Gets the root container
  78774. */
  78775. get rootContainer(): Container3D;
  78776. /**
  78777. * Gets a boolean indicating if the given control is in the root child list
  78778. * @param control defines the control to check
  78779. * @returns true if the control is in the root child list
  78780. */
  78781. containsControl(control: Control3D): boolean;
  78782. /**
  78783. * Adds a control to the root child list
  78784. * @param control defines the control to add
  78785. * @returns the current manager
  78786. */
  78787. addControl(control: Control3D): GUI3DManager;
  78788. /**
  78789. * Removes a control from the root child list
  78790. * @param control defines the control to remove
  78791. * @returns the current container
  78792. */
  78793. removeControl(control: Control3D): GUI3DManager;
  78794. /**
  78795. * Releases all associated resources
  78796. */
  78797. dispose(): void;
  78798. }
  78799. }
  78800. declare module BABYLON.GUI {
  78801. /**
  78802. * Class used to transport BABYLON.Vector3 information for pointer events
  78803. */
  78804. export class Vector3WithInfo extends BABYLON.Vector3 {
  78805. /** defines the current mouse button index */
  78806. buttonIndex: number;
  78807. /**
  78808. * Creates a new Vector3WithInfo
  78809. * @param source defines the vector3 data to transport
  78810. * @param buttonIndex defines the current mouse button index
  78811. */
  78812. constructor(source: BABYLON.Vector3,
  78813. /** defines the current mouse button index */
  78814. buttonIndex?: number);
  78815. }
  78816. }
  78817. declare module BABYLON.GUI {
  78818. /**
  78819. * Class used as base class for controls
  78820. */
  78821. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78822. /** Defines the control name */
  78823. name?: string | undefined;
  78824. /** @hidden */
  78825. _host: GUI3DManager;
  78826. private _node;
  78827. private _downCount;
  78828. private _enterCount;
  78829. private _downPointerIds;
  78830. private _isVisible;
  78831. /** Gets or sets the control position in world space */
  78832. get position(): BABYLON.Vector3;
  78833. set position(value: BABYLON.Vector3);
  78834. /** Gets or sets the control scaling in world space */
  78835. get scaling(): BABYLON.Vector3;
  78836. set scaling(value: BABYLON.Vector3);
  78837. /** Callback used to start pointer enter animation */
  78838. pointerEnterAnimation: () => void;
  78839. /** Callback used to start pointer out animation */
  78840. pointerOutAnimation: () => void;
  78841. /** Callback used to start pointer down animation */
  78842. pointerDownAnimation: () => void;
  78843. /** Callback used to start pointer up animation */
  78844. pointerUpAnimation: () => void;
  78845. /**
  78846. * An event triggered when the pointer move over the control
  78847. */
  78848. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78849. /**
  78850. * An event triggered when the pointer move out of the control
  78851. */
  78852. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78853. /**
  78854. * An event triggered when the pointer taps the control
  78855. */
  78856. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78857. /**
  78858. * An event triggered when pointer is up
  78859. */
  78860. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78861. /**
  78862. * An event triggered when a control is clicked on (with a mouse)
  78863. */
  78864. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78865. /**
  78866. * An event triggered when pointer enters the control
  78867. */
  78868. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78869. /**
  78870. * Gets or sets the parent container
  78871. */
  78872. parent: BABYLON.Nullable<Container3D>;
  78873. private _behaviors;
  78874. /**
  78875. * Gets the list of attached behaviors
  78876. * @see https://doc.babylonjs.com/features/behaviour
  78877. */
  78878. get behaviors(): BABYLON.Behavior<Control3D>[];
  78879. /**
  78880. * Attach a behavior to the control
  78881. * @see https://doc.babylonjs.com/features/behaviour
  78882. * @param behavior defines the behavior to attach
  78883. * @returns the current control
  78884. */
  78885. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78886. /**
  78887. * Remove an attached behavior
  78888. * @see https://doc.babylonjs.com/features/behaviour
  78889. * @param behavior defines the behavior to attach
  78890. * @returns the current control
  78891. */
  78892. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78893. /**
  78894. * Gets an attached behavior by name
  78895. * @param name defines the name of the behavior to look for
  78896. * @see https://doc.babylonjs.com/features/behaviour
  78897. * @returns null if behavior was not found else the requested behavior
  78898. */
  78899. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78900. /** Gets or sets a boolean indicating if the control is visible */
  78901. get isVisible(): boolean;
  78902. set isVisible(value: boolean);
  78903. /**
  78904. * Creates a new control
  78905. * @param name defines the control name
  78906. */
  78907. constructor(
  78908. /** Defines the control name */
  78909. name?: string | undefined);
  78910. /**
  78911. * Gets a string representing the class name
  78912. */
  78913. get typeName(): string;
  78914. /**
  78915. * Get the current class name of the control.
  78916. * @returns current class name
  78917. */
  78918. getClassName(): string;
  78919. protected _getTypeName(): string;
  78920. /**
  78921. * Gets the transform node used by this control
  78922. */
  78923. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78924. /**
  78925. * Gets the mesh used to render this control
  78926. */
  78927. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78928. /**
  78929. * Link the control as child of the given node
  78930. * @param node defines the node to link to. Use null to unlink the control
  78931. * @returns the current control
  78932. */
  78933. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78934. /** @hidden **/
  78935. _prepareNode(scene: BABYLON.Scene): void;
  78936. /**
  78937. * Node creation.
  78938. * Can be overriden by children
  78939. * @param scene defines the scene where the node must be attached
  78940. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78941. */
  78942. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78943. /**
  78944. * Affect a material to the given mesh
  78945. * @param mesh defines the mesh which will represent the control
  78946. */
  78947. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78948. /** @hidden */
  78949. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78950. /** @hidden */
  78951. _onPointerEnter(target: Control3D): boolean;
  78952. /** @hidden */
  78953. _onPointerOut(target: Control3D): void;
  78954. /** @hidden */
  78955. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78956. /** @hidden */
  78957. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78958. /** @hidden */
  78959. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78960. /** @hidden */
  78961. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78962. /** @hidden */
  78963. _disposeNode(): void;
  78964. /**
  78965. * Releases all associated resources
  78966. */
  78967. dispose(): void;
  78968. }
  78969. }
  78970. declare module BABYLON.GUI {
  78971. /**
  78972. * Class used as a root to all buttons
  78973. */
  78974. export class AbstractButton3D extends Control3D {
  78975. /**
  78976. * Creates a new button
  78977. * @param name defines the control name
  78978. */
  78979. constructor(name?: string);
  78980. protected _getTypeName(): string;
  78981. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78982. }
  78983. }
  78984. declare module BABYLON.GUI {
  78985. /**
  78986. * Class used to create a button in 3D
  78987. */
  78988. export class Button3D extends AbstractButton3D {
  78989. /** @hidden */
  78990. protected _currentMaterial: BABYLON.Material;
  78991. private _facadeTexture;
  78992. private _content;
  78993. private _contentResolution;
  78994. private _contentScaleRatio;
  78995. /**
  78996. * Gets or sets the texture resolution used to render content (512 by default)
  78997. */
  78998. get contentResolution(): BABYLON.int;
  78999. set contentResolution(value: BABYLON.int);
  79000. /**
  79001. * Gets or sets the texture scale ratio used to render content (2 by default)
  79002. */
  79003. get contentScaleRatio(): number;
  79004. set contentScaleRatio(value: number);
  79005. protected _disposeFacadeTexture(): void;
  79006. protected _resetContent(): void;
  79007. /**
  79008. * Creates a new button
  79009. * @param name defines the control name
  79010. */
  79011. constructor(name?: string);
  79012. /**
  79013. * Gets or sets the GUI 2D content used to display the button's facade
  79014. */
  79015. get content(): Control;
  79016. set content(value: Control);
  79017. /**
  79018. * Apply the facade texture (created from the content property).
  79019. * This function can be overloaded by child classes
  79020. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79021. */
  79022. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79023. protected _getTypeName(): string;
  79024. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79025. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79026. /**
  79027. * Releases all associated resources
  79028. */
  79029. dispose(): void;
  79030. }
  79031. }
  79032. declare module BABYLON.GUI {
  79033. /**
  79034. * Abstract class used to create a container panel deployed on the surface of a volume
  79035. */
  79036. export abstract class VolumeBasedPanel extends Container3D {
  79037. private _columns;
  79038. private _rows;
  79039. private _rowThenColum;
  79040. private _orientation;
  79041. protected _cellWidth: number;
  79042. protected _cellHeight: number;
  79043. /**
  79044. * Gets or sets the distance between elements
  79045. */
  79046. margin: number;
  79047. /**
  79048. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79049. * | Value | Type | Description |
  79050. * | ----- | ----------------------------------- | ----------- |
  79051. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79052. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79053. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79054. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79055. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79056. */
  79057. get orientation(): number;
  79058. set orientation(value: number);
  79059. /**
  79060. * Gets or sets the number of columns requested (10 by default).
  79061. * The panel will automatically compute the number of rows based on number of child controls.
  79062. */
  79063. get columns(): BABYLON.int;
  79064. set columns(value: BABYLON.int);
  79065. /**
  79066. * Gets or sets a the number of rows requested.
  79067. * The panel will automatically compute the number of columns based on number of child controls.
  79068. */
  79069. get rows(): BABYLON.int;
  79070. set rows(value: BABYLON.int);
  79071. /**
  79072. * Creates new VolumeBasedPanel
  79073. */
  79074. constructor();
  79075. protected _arrangeChildren(): void;
  79076. /** Child classes must implement this function to provide correct control positioning */
  79077. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79078. /** Child classes can implement this function to provide additional processing */
  79079. protected _finalProcessing(): void;
  79080. }
  79081. }
  79082. declare module BABYLON.GUI {
  79083. /**
  79084. * Class used to create a container panel deployed on the surface of a cylinder
  79085. */
  79086. export class CylinderPanel extends VolumeBasedPanel {
  79087. private _radius;
  79088. /**
  79089. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79090. */
  79091. get radius(): BABYLON.float;
  79092. set radius(value: BABYLON.float);
  79093. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79094. private _cylindricalMapping;
  79095. }
  79096. }
  79097. declare module BABYLON.GUI {
  79098. /** @hidden */
  79099. export var fluentVertexShader: {
  79100. name: string;
  79101. shader: string;
  79102. };
  79103. }
  79104. declare module BABYLON.GUI {
  79105. /** @hidden */
  79106. export var fluentPixelShader: {
  79107. name: string;
  79108. shader: string;
  79109. };
  79110. }
  79111. declare module BABYLON.GUI {
  79112. /** @hidden */
  79113. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79114. INNERGLOW: boolean;
  79115. BORDER: boolean;
  79116. HOVERLIGHT: boolean;
  79117. TEXTURE: boolean;
  79118. constructor();
  79119. }
  79120. /**
  79121. * Class used to render controls with fluent desgin
  79122. */
  79123. export class FluentMaterial extends BABYLON.PushMaterial {
  79124. /**
  79125. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79126. */
  79127. innerGlowColorIntensity: number;
  79128. /**
  79129. * Gets or sets the inner glow color (white by default)
  79130. */
  79131. innerGlowColor: BABYLON.Color3;
  79132. /**
  79133. * Gets or sets alpha value (default is 1.0)
  79134. */
  79135. alpha: number;
  79136. /**
  79137. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79138. */
  79139. albedoColor: BABYLON.Color3;
  79140. /**
  79141. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79142. */
  79143. renderBorders: boolean;
  79144. /**
  79145. * Gets or sets border width (default is 0.5)
  79146. */
  79147. borderWidth: number;
  79148. /**
  79149. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79150. */
  79151. edgeSmoothingValue: number;
  79152. /**
  79153. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79154. */
  79155. borderMinValue: number;
  79156. /**
  79157. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79158. */
  79159. renderHoverLight: boolean;
  79160. /**
  79161. * Gets or sets the radius used to render the hover light (default is 1.0)
  79162. */
  79163. hoverRadius: number;
  79164. /**
  79165. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79166. */
  79167. hoverColor: BABYLON.Color4;
  79168. /**
  79169. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79170. */
  79171. hoverPosition: BABYLON.Vector3;
  79172. private _albedoTexture;
  79173. /** Gets or sets the texture to use for albedo color */
  79174. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79175. /**
  79176. * Creates a new Fluent material
  79177. * @param name defines the name of the material
  79178. * @param scene defines the hosting scene
  79179. */
  79180. constructor(name: string, scene: BABYLON.Scene);
  79181. needAlphaBlending(): boolean;
  79182. needAlphaTesting(): boolean;
  79183. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79186. getActiveTextures(): BABYLON.BaseTexture[];
  79187. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79188. dispose(forceDisposeEffect?: boolean): void;
  79189. clone(name: string): FluentMaterial;
  79190. serialize(): any;
  79191. getClassName(): string;
  79192. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79193. }
  79194. }
  79195. declare module BABYLON.GUI {
  79196. /**
  79197. * Class used to create a holographic button in 3D
  79198. */
  79199. export class HolographicButton extends Button3D {
  79200. private _backPlate;
  79201. private _textPlate;
  79202. private _frontPlate;
  79203. private _text;
  79204. private _imageUrl;
  79205. private _shareMaterials;
  79206. private _frontMaterial;
  79207. private _backMaterial;
  79208. private _plateMaterial;
  79209. private _pickedPointObserver;
  79210. private _tooltipFade;
  79211. private _tooltipTextBlock;
  79212. private _tooltipTexture;
  79213. private _tooltipMesh;
  79214. private _tooltipHoverObserver;
  79215. private _tooltipOutObserver;
  79216. private _disposeTooltip;
  79217. /**
  79218. * Rendering ground id of all the mesh in the button
  79219. */
  79220. set renderingGroupId(id: number);
  79221. get renderingGroupId(): number;
  79222. /**
  79223. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79224. */
  79225. set tooltipText(text: BABYLON.Nullable<string>);
  79226. get tooltipText(): BABYLON.Nullable<string>;
  79227. /**
  79228. * Gets or sets text for the button
  79229. */
  79230. get text(): string;
  79231. set text(value: string);
  79232. /**
  79233. * Gets or sets the image url for the button
  79234. */
  79235. get imageUrl(): string;
  79236. set imageUrl(value: string);
  79237. /**
  79238. * Gets the back material used by this button
  79239. */
  79240. get backMaterial(): FluentMaterial;
  79241. /**
  79242. * Gets the front material used by this button
  79243. */
  79244. get frontMaterial(): FluentMaterial;
  79245. /**
  79246. * Gets the plate material used by this button
  79247. */
  79248. get plateMaterial(): BABYLON.StandardMaterial;
  79249. /**
  79250. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79251. */
  79252. get shareMaterials(): boolean;
  79253. /**
  79254. * Creates a new button
  79255. * @param name defines the control name
  79256. */
  79257. constructor(name?: string, shareMaterials?: boolean);
  79258. protected _getTypeName(): string;
  79259. private _rebuildContent;
  79260. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79261. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79262. private _createBackMaterial;
  79263. private _createFrontMaterial;
  79264. private _createPlateMaterial;
  79265. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79266. /**
  79267. * Releases all associated resources
  79268. */
  79269. dispose(): void;
  79270. }
  79271. }
  79272. declare module BABYLON.GUI {
  79273. /**
  79274. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79275. */
  79276. export class MeshButton3D extends Button3D {
  79277. /** @hidden */
  79278. protected _currentMesh: BABYLON.Mesh;
  79279. /**
  79280. * Creates a new 3D button based on a mesh
  79281. * @param mesh mesh to become a 3D button
  79282. * @param name defines the control name
  79283. */
  79284. constructor(mesh: BABYLON.Mesh, name?: string);
  79285. protected _getTypeName(): string;
  79286. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79287. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79288. }
  79289. }
  79290. declare module BABYLON.GUI {
  79291. /**
  79292. * Class used to create a container panel deployed on the surface of a plane
  79293. */
  79294. export class PlanePanel extends VolumeBasedPanel {
  79295. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79296. }
  79297. }
  79298. declare module BABYLON.GUI {
  79299. /**
  79300. * Class used to create a container panel where items get randomized planar mapping
  79301. */
  79302. export class ScatterPanel extends VolumeBasedPanel {
  79303. private _iteration;
  79304. /**
  79305. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79306. */
  79307. get iteration(): BABYLON.float;
  79308. set iteration(value: BABYLON.float);
  79309. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79310. private _scatterMapping;
  79311. protected _finalProcessing(): void;
  79312. }
  79313. }
  79314. declare module BABYLON.GUI {
  79315. /**
  79316. * Class used to create a container panel deployed on the surface of a sphere
  79317. */
  79318. export class SpherePanel extends VolumeBasedPanel {
  79319. private _radius;
  79320. /**
  79321. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79322. */
  79323. get radius(): BABYLON.float;
  79324. set radius(value: BABYLON.float);
  79325. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79326. private _sphericalMapping;
  79327. }
  79328. }
  79329. declare module BABYLON.GUI {
  79330. /**
  79331. * Class used to create a stack panel in 3D on XY plane
  79332. */
  79333. export class StackPanel3D extends Container3D {
  79334. private _isVertical;
  79335. /**
  79336. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79337. */
  79338. get isVertical(): boolean;
  79339. set isVertical(value: boolean);
  79340. /**
  79341. * Gets or sets the distance between elements
  79342. */
  79343. margin: number;
  79344. /**
  79345. * Creates new StackPanel
  79346. * @param isVertical
  79347. */
  79348. constructor(isVertical?: boolean);
  79349. protected _arrangeChildren(): void;
  79350. }
  79351. }
  79352. declare module BABYLON {
  79353. /**
  79354. * Configuration for glTF validation
  79355. */
  79356. export interface IGLTFValidationConfiguration {
  79357. /**
  79358. * The url of the glTF validator.
  79359. */
  79360. url: string;
  79361. }
  79362. /**
  79363. * glTF validation
  79364. */
  79365. export class GLTFValidation {
  79366. /**
  79367. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79368. */
  79369. static Configuration: IGLTFValidationConfiguration;
  79370. private static _LoadScriptPromise;
  79371. /**
  79372. * Validate a glTF asset using the glTF-Validator.
  79373. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79374. * @param rootUrl The root url for the glTF
  79375. * @param fileName The file name for the glTF
  79376. * @param getExternalResource The callback to get external resources for the glTF validator
  79377. * @returns A promise that resolves with the glTF validation results once complete
  79378. */
  79379. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79380. }
  79381. }
  79382. declare module BABYLON {
  79383. /**
  79384. * Mode that determines the coordinate system to use.
  79385. */
  79386. export enum GLTFLoaderCoordinateSystemMode {
  79387. /**
  79388. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79389. */
  79390. AUTO = 0,
  79391. /**
  79392. * Sets the useRightHandedSystem flag on the scene.
  79393. */
  79394. FORCE_RIGHT_HANDED = 1
  79395. }
  79396. /**
  79397. * Mode that determines what animations will start.
  79398. */
  79399. export enum GLTFLoaderAnimationStartMode {
  79400. /**
  79401. * No animation will start.
  79402. */
  79403. NONE = 0,
  79404. /**
  79405. * The first animation will start.
  79406. */
  79407. FIRST = 1,
  79408. /**
  79409. * All animations will start.
  79410. */
  79411. ALL = 2
  79412. }
  79413. /**
  79414. * Interface that contains the data for the glTF asset.
  79415. */
  79416. export interface IGLTFLoaderData {
  79417. /**
  79418. * The object that represents the glTF JSON.
  79419. */
  79420. json: Object;
  79421. /**
  79422. * The BIN chunk of a binary glTF.
  79423. */
  79424. bin: Nullable<IDataBuffer>;
  79425. }
  79426. /**
  79427. * Interface for extending the loader.
  79428. */
  79429. export interface IGLTFLoaderExtension {
  79430. /**
  79431. * The name of this extension.
  79432. */
  79433. readonly name: string;
  79434. /**
  79435. * Defines whether this extension is enabled.
  79436. */
  79437. enabled: boolean;
  79438. /**
  79439. * Defines the order of this extension.
  79440. * The loader sorts the extensions using these values when loading.
  79441. */
  79442. order?: number;
  79443. }
  79444. /**
  79445. * Loader state.
  79446. */
  79447. export enum GLTFLoaderState {
  79448. /**
  79449. * The asset is loading.
  79450. */
  79451. LOADING = 0,
  79452. /**
  79453. * The asset is ready for rendering.
  79454. */
  79455. READY = 1,
  79456. /**
  79457. * The asset is completely loaded.
  79458. */
  79459. COMPLETE = 2
  79460. }
  79461. /** @hidden */
  79462. export interface IImportMeshAsyncOutput {
  79463. meshes: AbstractMesh[];
  79464. particleSystems: IParticleSystem[];
  79465. skeletons: Skeleton[];
  79466. animationGroups: AnimationGroup[];
  79467. lights: Light[];
  79468. transformNodes: TransformNode[];
  79469. }
  79470. /** @hidden */
  79471. export interface IGLTFLoader extends IDisposable {
  79472. readonly state: Nullable<GLTFLoaderState>;
  79473. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79474. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79475. }
  79476. /**
  79477. * File loader for loading glTF files into a scene.
  79478. */
  79479. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79480. /** @hidden */
  79481. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79482. /** @hidden */
  79483. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79484. /**
  79485. * Raised when the asset has been parsed
  79486. */
  79487. onParsedObservable: Observable<IGLTFLoaderData>;
  79488. private _onParsedObserver;
  79489. /**
  79490. * Raised when the asset has been parsed
  79491. */
  79492. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79493. /**
  79494. * 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.
  79495. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79496. * Defaults to true.
  79497. * @hidden
  79498. */
  79499. static IncrementalLoading: boolean;
  79500. /**
  79501. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79502. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79503. * @hidden
  79504. */
  79505. static HomogeneousCoordinates: boolean;
  79506. /**
  79507. * The coordinate system mode. Defaults to AUTO.
  79508. */
  79509. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79510. /**
  79511. * The animation start mode. Defaults to FIRST.
  79512. */
  79513. animationStartMode: GLTFLoaderAnimationStartMode;
  79514. /**
  79515. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79516. */
  79517. compileMaterials: boolean;
  79518. /**
  79519. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79520. */
  79521. useClipPlane: boolean;
  79522. /**
  79523. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79524. */
  79525. compileShadowGenerators: boolean;
  79526. /**
  79527. * Defines if the Alpha blended materials are only applied as coverage.
  79528. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79529. * If true, no extra effects are applied to transparent pixels.
  79530. */
  79531. transparencyAsCoverage: boolean;
  79532. /**
  79533. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79534. * Enabling will disable offline support and glTF validator.
  79535. * Defaults to false.
  79536. */
  79537. useRangeRequests: boolean;
  79538. /**
  79539. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79540. */
  79541. createInstances: boolean;
  79542. /**
  79543. * 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.
  79544. */
  79545. alwaysComputeBoundingBox: boolean;
  79546. /**
  79547. * Function called before loading a url referenced by the asset.
  79548. */
  79549. preprocessUrlAsync: (url: string) => Promise<string>;
  79550. /**
  79551. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79552. */
  79553. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79554. private _onMeshLoadedObserver;
  79555. /**
  79556. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79557. */
  79558. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79559. /**
  79560. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79561. */
  79562. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79563. private _onTextureLoadedObserver;
  79564. /**
  79565. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79566. */
  79567. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79568. /**
  79569. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79570. */
  79571. readonly onMaterialLoadedObservable: Observable<Material>;
  79572. private _onMaterialLoadedObserver;
  79573. /**
  79574. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79575. */
  79576. set onMaterialLoaded(callback: (material: Material) => void);
  79577. /**
  79578. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79579. */
  79580. readonly onCameraLoadedObservable: Observable<Camera>;
  79581. private _onCameraLoadedObserver;
  79582. /**
  79583. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79584. */
  79585. set onCameraLoaded(callback: (camera: Camera) => void);
  79586. /**
  79587. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79588. * For assets with LODs, raised when all of the LODs are complete.
  79589. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79590. */
  79591. readonly onCompleteObservable: Observable<void>;
  79592. private _onCompleteObserver;
  79593. /**
  79594. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79595. * For assets with LODs, raised when all of the LODs are complete.
  79596. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79597. */
  79598. set onComplete(callback: () => void);
  79599. /**
  79600. * Observable raised when an error occurs.
  79601. */
  79602. readonly onErrorObservable: Observable<any>;
  79603. private _onErrorObserver;
  79604. /**
  79605. * Callback raised when an error occurs.
  79606. */
  79607. set onError(callback: (reason: any) => void);
  79608. /**
  79609. * Observable raised after the loader is disposed.
  79610. */
  79611. readonly onDisposeObservable: Observable<void>;
  79612. private _onDisposeObserver;
  79613. /**
  79614. * Callback raised after the loader is disposed.
  79615. */
  79616. set onDispose(callback: () => void);
  79617. /**
  79618. * Observable raised after a loader extension is created.
  79619. * Set additional options for a loader extension in this event.
  79620. */
  79621. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79622. private _onExtensionLoadedObserver;
  79623. /**
  79624. * Callback raised after a loader extension is created.
  79625. */
  79626. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79627. /**
  79628. * Defines if the loader logging is enabled.
  79629. */
  79630. get loggingEnabled(): boolean;
  79631. set loggingEnabled(value: boolean);
  79632. /**
  79633. * Defines if the loader should capture performance counters.
  79634. */
  79635. get capturePerformanceCounters(): boolean;
  79636. set capturePerformanceCounters(value: boolean);
  79637. /**
  79638. * Defines if the loader should validate the asset.
  79639. */
  79640. validate: boolean;
  79641. /**
  79642. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79643. */
  79644. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79645. private _onValidatedObserver;
  79646. /**
  79647. * Callback raised after a loader extension is created.
  79648. */
  79649. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79650. private _loader;
  79651. private _progressCallback?;
  79652. private _requests;
  79653. private static magicBase64Encoded;
  79654. /**
  79655. * Name of the loader ("gltf")
  79656. */
  79657. name: string;
  79658. /** @hidden */
  79659. extensions: ISceneLoaderPluginExtensions;
  79660. /**
  79661. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79662. */
  79663. dispose(): void;
  79664. /** @hidden */
  79665. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79666. /** @hidden */
  79667. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79668. /** @hidden */
  79669. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79670. meshes: AbstractMesh[];
  79671. particleSystems: IParticleSystem[];
  79672. skeletons: Skeleton[];
  79673. animationGroups: AnimationGroup[];
  79674. }>;
  79675. /** @hidden */
  79676. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79677. /** @hidden */
  79678. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79679. /** @hidden */
  79680. canDirectLoad(data: string): boolean;
  79681. /** @hidden */
  79682. directLoad(scene: Scene, data: string): Promise<any>;
  79683. /**
  79684. * The callback that allows custom handling of the root url based on the response url.
  79685. * @param rootUrl the original root url
  79686. * @param responseURL the response url if available
  79687. * @returns the new root url
  79688. */
  79689. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79690. /** @hidden */
  79691. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79692. /**
  79693. * The loader state or null if the loader is not active.
  79694. */
  79695. get loaderState(): Nullable<GLTFLoaderState>;
  79696. /**
  79697. * Returns a promise that resolves when the asset is completely loaded.
  79698. * @returns a promise that resolves when the asset is completely loaded.
  79699. */
  79700. whenCompleteAsync(): Promise<void>;
  79701. /** @hidden */
  79702. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79703. /** @hidden */
  79704. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79705. private _onProgress;
  79706. private _validate;
  79707. private _getLoader;
  79708. private _parseJson;
  79709. private _unpackBinaryAsync;
  79710. private _unpackBinaryV1Async;
  79711. private _unpackBinaryV2Async;
  79712. private static _parseVersion;
  79713. private static _compareVersion;
  79714. private static readonly _logSpaces;
  79715. private _logIndentLevel;
  79716. private _loggingEnabled;
  79717. /** @hidden */
  79718. _log: (message: string) => void;
  79719. /** @hidden */
  79720. _logOpen(message: string): void;
  79721. /** @hidden */
  79722. _logClose(): void;
  79723. private _logEnabled;
  79724. private _logDisabled;
  79725. private _capturePerformanceCounters;
  79726. /** @hidden */
  79727. _startPerformanceCounter: (counterName: string) => void;
  79728. /** @hidden */
  79729. _endPerformanceCounter: (counterName: string) => void;
  79730. private _startPerformanceCounterEnabled;
  79731. private _startPerformanceCounterDisabled;
  79732. private _endPerformanceCounterEnabled;
  79733. private _endPerformanceCounterDisabled;
  79734. }
  79735. }
  79736. declare module BABYLON.GLTF1 {
  79737. /**
  79738. * Enums
  79739. * @hidden
  79740. */
  79741. export enum EComponentType {
  79742. BYTE = 5120,
  79743. UNSIGNED_BYTE = 5121,
  79744. SHORT = 5122,
  79745. UNSIGNED_SHORT = 5123,
  79746. FLOAT = 5126
  79747. }
  79748. /** @hidden */
  79749. export enum EShaderType {
  79750. FRAGMENT = 35632,
  79751. VERTEX = 35633
  79752. }
  79753. /** @hidden */
  79754. export enum EParameterType {
  79755. BYTE = 5120,
  79756. UNSIGNED_BYTE = 5121,
  79757. SHORT = 5122,
  79758. UNSIGNED_SHORT = 5123,
  79759. INT = 5124,
  79760. UNSIGNED_INT = 5125,
  79761. FLOAT = 5126,
  79762. FLOAT_VEC2 = 35664,
  79763. FLOAT_VEC3 = 35665,
  79764. FLOAT_VEC4 = 35666,
  79765. INT_VEC2 = 35667,
  79766. INT_VEC3 = 35668,
  79767. INT_VEC4 = 35669,
  79768. BOOL = 35670,
  79769. BOOL_VEC2 = 35671,
  79770. BOOL_VEC3 = 35672,
  79771. BOOL_VEC4 = 35673,
  79772. FLOAT_MAT2 = 35674,
  79773. FLOAT_MAT3 = 35675,
  79774. FLOAT_MAT4 = 35676,
  79775. SAMPLER_2D = 35678
  79776. }
  79777. /** @hidden */
  79778. export enum ETextureWrapMode {
  79779. CLAMP_TO_EDGE = 33071,
  79780. MIRRORED_REPEAT = 33648,
  79781. REPEAT = 10497
  79782. }
  79783. /** @hidden */
  79784. export enum ETextureFilterType {
  79785. NEAREST = 9728,
  79786. LINEAR = 9728,
  79787. NEAREST_MIPMAP_NEAREST = 9984,
  79788. LINEAR_MIPMAP_NEAREST = 9985,
  79789. NEAREST_MIPMAP_LINEAR = 9986,
  79790. LINEAR_MIPMAP_LINEAR = 9987
  79791. }
  79792. /** @hidden */
  79793. export enum ETextureFormat {
  79794. ALPHA = 6406,
  79795. RGB = 6407,
  79796. RGBA = 6408,
  79797. LUMINANCE = 6409,
  79798. LUMINANCE_ALPHA = 6410
  79799. }
  79800. /** @hidden */
  79801. export enum ECullingType {
  79802. FRONT = 1028,
  79803. BACK = 1029,
  79804. FRONT_AND_BACK = 1032
  79805. }
  79806. /** @hidden */
  79807. export enum EBlendingFunction {
  79808. ZERO = 0,
  79809. ONE = 1,
  79810. SRC_COLOR = 768,
  79811. ONE_MINUS_SRC_COLOR = 769,
  79812. DST_COLOR = 774,
  79813. ONE_MINUS_DST_COLOR = 775,
  79814. SRC_ALPHA = 770,
  79815. ONE_MINUS_SRC_ALPHA = 771,
  79816. DST_ALPHA = 772,
  79817. ONE_MINUS_DST_ALPHA = 773,
  79818. CONSTANT_COLOR = 32769,
  79819. ONE_MINUS_CONSTANT_COLOR = 32770,
  79820. CONSTANT_ALPHA = 32771,
  79821. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79822. SRC_ALPHA_SATURATE = 776
  79823. }
  79824. /** @hidden */
  79825. export interface IGLTFProperty {
  79826. extensions?: {
  79827. [key: string]: any;
  79828. };
  79829. extras?: Object;
  79830. }
  79831. /** @hidden */
  79832. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79833. name?: string;
  79834. }
  79835. /** @hidden */
  79836. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79837. bufferView: string;
  79838. byteOffset: number;
  79839. byteStride: number;
  79840. count: number;
  79841. type: string;
  79842. componentType: EComponentType;
  79843. max?: number[];
  79844. min?: number[];
  79845. name?: string;
  79846. }
  79847. /** @hidden */
  79848. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79849. buffer: string;
  79850. byteOffset: number;
  79851. byteLength: number;
  79852. byteStride: number;
  79853. target?: number;
  79854. }
  79855. /** @hidden */
  79856. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79857. uri: string;
  79858. byteLength?: number;
  79859. type?: string;
  79860. }
  79861. /** @hidden */
  79862. export interface IGLTFShader extends IGLTFChildRootProperty {
  79863. uri: string;
  79864. type: EShaderType;
  79865. }
  79866. /** @hidden */
  79867. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79868. attributes: string[];
  79869. fragmentShader: string;
  79870. vertexShader: string;
  79871. }
  79872. /** @hidden */
  79873. export interface IGLTFTechniqueParameter {
  79874. type: number;
  79875. count?: number;
  79876. semantic?: string;
  79877. node?: string;
  79878. value?: number | boolean | string | Array<any>;
  79879. source?: string;
  79880. babylonValue?: any;
  79881. }
  79882. /** @hidden */
  79883. export interface IGLTFTechniqueCommonProfile {
  79884. lightingModel: string;
  79885. texcoordBindings: Object;
  79886. parameters?: Array<any>;
  79887. }
  79888. /** @hidden */
  79889. export interface IGLTFTechniqueStatesFunctions {
  79890. blendColor?: number[];
  79891. blendEquationSeparate?: number[];
  79892. blendFuncSeparate?: number[];
  79893. colorMask: boolean[];
  79894. cullFace: number[];
  79895. }
  79896. /** @hidden */
  79897. export interface IGLTFTechniqueStates {
  79898. enable: number[];
  79899. functions: IGLTFTechniqueStatesFunctions;
  79900. }
  79901. /** @hidden */
  79902. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79903. parameters: {
  79904. [key: string]: IGLTFTechniqueParameter;
  79905. };
  79906. program: string;
  79907. attributes: {
  79908. [key: string]: string;
  79909. };
  79910. uniforms: {
  79911. [key: string]: string;
  79912. };
  79913. states: IGLTFTechniqueStates;
  79914. }
  79915. /** @hidden */
  79916. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79917. technique?: string;
  79918. values: string[];
  79919. }
  79920. /** @hidden */
  79921. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79922. attributes: {
  79923. [key: string]: string;
  79924. };
  79925. indices: string;
  79926. material: string;
  79927. mode?: number;
  79928. }
  79929. /** @hidden */
  79930. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79931. primitives: IGLTFMeshPrimitive[];
  79932. }
  79933. /** @hidden */
  79934. export interface IGLTFImage extends IGLTFChildRootProperty {
  79935. uri: string;
  79936. }
  79937. /** @hidden */
  79938. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79939. magFilter?: number;
  79940. minFilter?: number;
  79941. wrapS?: number;
  79942. wrapT?: number;
  79943. }
  79944. /** @hidden */
  79945. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79946. sampler: string;
  79947. source: string;
  79948. format?: ETextureFormat;
  79949. internalFormat?: ETextureFormat;
  79950. target?: number;
  79951. type?: number;
  79952. babylonTexture?: Texture;
  79953. }
  79954. /** @hidden */
  79955. export interface IGLTFAmbienLight {
  79956. color?: number[];
  79957. }
  79958. /** @hidden */
  79959. export interface IGLTFDirectionalLight {
  79960. color?: number[];
  79961. }
  79962. /** @hidden */
  79963. export interface IGLTFPointLight {
  79964. color?: number[];
  79965. constantAttenuation?: number;
  79966. linearAttenuation?: number;
  79967. quadraticAttenuation?: number;
  79968. }
  79969. /** @hidden */
  79970. export interface IGLTFSpotLight {
  79971. color?: number[];
  79972. constantAttenuation?: number;
  79973. fallOfAngle?: number;
  79974. fallOffExponent?: number;
  79975. linearAttenuation?: number;
  79976. quadraticAttenuation?: number;
  79977. }
  79978. /** @hidden */
  79979. export interface IGLTFLight extends IGLTFChildRootProperty {
  79980. type: string;
  79981. }
  79982. /** @hidden */
  79983. export interface IGLTFCameraOrthographic {
  79984. xmag: number;
  79985. ymag: number;
  79986. zfar: number;
  79987. znear: number;
  79988. }
  79989. /** @hidden */
  79990. export interface IGLTFCameraPerspective {
  79991. aspectRatio: number;
  79992. yfov: number;
  79993. zfar: number;
  79994. znear: number;
  79995. }
  79996. /** @hidden */
  79997. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79998. type: string;
  79999. }
  80000. /** @hidden */
  80001. export interface IGLTFAnimationChannelTarget {
  80002. id: string;
  80003. path: string;
  80004. }
  80005. /** @hidden */
  80006. export interface IGLTFAnimationChannel {
  80007. sampler: string;
  80008. target: IGLTFAnimationChannelTarget;
  80009. }
  80010. /** @hidden */
  80011. export interface IGLTFAnimationSampler {
  80012. input: string;
  80013. output: string;
  80014. interpolation?: string;
  80015. }
  80016. /** @hidden */
  80017. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80018. channels?: IGLTFAnimationChannel[];
  80019. parameters?: {
  80020. [key: string]: string;
  80021. };
  80022. samplers?: {
  80023. [key: string]: IGLTFAnimationSampler;
  80024. };
  80025. }
  80026. /** @hidden */
  80027. export interface IGLTFNodeInstanceSkin {
  80028. skeletons: string[];
  80029. skin: string;
  80030. meshes: string[];
  80031. }
  80032. /** @hidden */
  80033. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80034. bindShapeMatrix: number[];
  80035. inverseBindMatrices: string;
  80036. jointNames: string[];
  80037. babylonSkeleton?: Skeleton;
  80038. }
  80039. /** @hidden */
  80040. export interface IGLTFNode extends IGLTFChildRootProperty {
  80041. camera?: string;
  80042. children: string[];
  80043. skin?: string;
  80044. jointName?: string;
  80045. light?: string;
  80046. matrix: number[];
  80047. mesh?: string;
  80048. meshes?: string[];
  80049. rotation?: number[];
  80050. scale?: number[];
  80051. translation?: number[];
  80052. babylonNode?: Node;
  80053. }
  80054. /** @hidden */
  80055. export interface IGLTFScene extends IGLTFChildRootProperty {
  80056. nodes: string[];
  80057. }
  80058. /** @hidden */
  80059. export interface IGLTFRuntime {
  80060. extensions: {
  80061. [key: string]: any;
  80062. };
  80063. accessors: {
  80064. [key: string]: IGLTFAccessor;
  80065. };
  80066. buffers: {
  80067. [key: string]: IGLTFBuffer;
  80068. };
  80069. bufferViews: {
  80070. [key: string]: IGLTFBufferView;
  80071. };
  80072. meshes: {
  80073. [key: string]: IGLTFMesh;
  80074. };
  80075. lights: {
  80076. [key: string]: IGLTFLight;
  80077. };
  80078. cameras: {
  80079. [key: string]: IGLTFCamera;
  80080. };
  80081. nodes: {
  80082. [key: string]: IGLTFNode;
  80083. };
  80084. images: {
  80085. [key: string]: IGLTFImage;
  80086. };
  80087. textures: {
  80088. [key: string]: IGLTFTexture;
  80089. };
  80090. shaders: {
  80091. [key: string]: IGLTFShader;
  80092. };
  80093. programs: {
  80094. [key: string]: IGLTFProgram;
  80095. };
  80096. samplers: {
  80097. [key: string]: IGLTFSampler;
  80098. };
  80099. techniques: {
  80100. [key: string]: IGLTFTechnique;
  80101. };
  80102. materials: {
  80103. [key: string]: IGLTFMaterial;
  80104. };
  80105. animations: {
  80106. [key: string]: IGLTFAnimation;
  80107. };
  80108. skins: {
  80109. [key: string]: IGLTFSkins;
  80110. };
  80111. currentScene?: Object;
  80112. scenes: {
  80113. [key: string]: IGLTFScene;
  80114. };
  80115. extensionsUsed: string[];
  80116. extensionsRequired?: string[];
  80117. buffersCount: number;
  80118. shaderscount: number;
  80119. scene: Scene;
  80120. rootUrl: string;
  80121. loadedBufferCount: number;
  80122. loadedBufferViews: {
  80123. [name: string]: ArrayBufferView;
  80124. };
  80125. loadedShaderCount: number;
  80126. importOnlyMeshes: boolean;
  80127. importMeshesNames?: string[];
  80128. dummyNodes: Node[];
  80129. forAssetContainer: boolean;
  80130. }
  80131. /** @hidden */
  80132. export interface INodeToRoot {
  80133. bone: Bone;
  80134. node: IGLTFNode;
  80135. id: string;
  80136. }
  80137. /** @hidden */
  80138. export interface IJointNode {
  80139. node: IGLTFNode;
  80140. id: string;
  80141. }
  80142. }
  80143. declare module BABYLON.GLTF1 {
  80144. /**
  80145. * Utils functions for GLTF
  80146. * @hidden
  80147. */
  80148. export class GLTFUtils {
  80149. /**
  80150. * Sets the given "parameter" matrix
  80151. * @param scene: the Scene object
  80152. * @param source: the source node where to pick the matrix
  80153. * @param parameter: the GLTF technique parameter
  80154. * @param uniformName: the name of the shader's uniform
  80155. * @param shaderMaterial: the shader material
  80156. */
  80157. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80158. /**
  80159. * Sets the given "parameter" matrix
  80160. * @param shaderMaterial: the shader material
  80161. * @param uniform: the name of the shader's uniform
  80162. * @param value: the value of the uniform
  80163. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80164. */
  80165. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80166. /**
  80167. * Returns the wrap mode of the texture
  80168. * @param mode: the mode value
  80169. */
  80170. static GetWrapMode(mode: number): number;
  80171. /**
  80172. * Returns the byte stride giving an accessor
  80173. * @param accessor: the GLTF accessor objet
  80174. */
  80175. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80176. /**
  80177. * Returns the texture filter mode giving a mode value
  80178. * @param mode: the filter mode value
  80179. */
  80180. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80181. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80182. /**
  80183. * Returns a buffer from its accessor
  80184. * @param gltfRuntime: the GLTF runtime
  80185. * @param accessor: the GLTF accessor
  80186. */
  80187. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80188. /**
  80189. * Decodes a buffer view into a string
  80190. * @param view: the buffer view
  80191. */
  80192. static DecodeBufferToText(view: ArrayBufferView): string;
  80193. /**
  80194. * Returns the default material of gltf. Related to
  80195. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80196. * @param scene: the Babylon.js scene
  80197. */
  80198. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80199. private static _DefaultMaterial;
  80200. }
  80201. }
  80202. declare module BABYLON.GLTF1 {
  80203. /**
  80204. * Implementation of the base glTF spec
  80205. * @hidden
  80206. */
  80207. export class GLTFLoaderBase {
  80208. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80209. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80210. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80211. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80212. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80213. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80214. }
  80215. /**
  80216. * glTF V1 Loader
  80217. * @hidden
  80218. */
  80219. export class GLTFLoader implements IGLTFLoader {
  80220. static Extensions: {
  80221. [name: string]: GLTFLoaderExtension;
  80222. };
  80223. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80224. state: Nullable<GLTFLoaderState>;
  80225. dispose(): void;
  80226. private _importMeshAsync;
  80227. /**
  80228. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80229. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80230. * @param scene the scene the meshes should be added to
  80231. * @param forAssetContainer defines if the entities must be stored in the scene
  80232. * @param data gltf data containing information of the meshes in a loaded file
  80233. * @param rootUrl root url to load from
  80234. * @param onProgress event that fires when loading progress has occured
  80235. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80236. */
  80237. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80238. private _loadAsync;
  80239. /**
  80240. * Imports all objects from a loaded gltf file and adds them to the scene
  80241. * @param scene the scene the objects should be added to
  80242. * @param data gltf data containing information of the meshes in a loaded file
  80243. * @param rootUrl root url to load from
  80244. * @param onProgress event that fires when loading progress has occured
  80245. * @returns a promise which completes when objects have been loaded to the scene
  80246. */
  80247. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80248. private _loadShadersAsync;
  80249. private _loadBuffersAsync;
  80250. private _createNodes;
  80251. }
  80252. /** @hidden */
  80253. export abstract class GLTFLoaderExtension {
  80254. private _name;
  80255. constructor(name: string);
  80256. get name(): string;
  80257. /**
  80258. * Defines an override for loading the runtime
  80259. * Return true to stop further extensions from loading the runtime
  80260. */
  80261. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80262. /**
  80263. * Defines an onverride for creating gltf runtime
  80264. * Return true to stop further extensions from creating the runtime
  80265. */
  80266. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80267. /**
  80268. * Defines an override for loading buffers
  80269. * Return true to stop further extensions from loading this buffer
  80270. */
  80271. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80272. /**
  80273. * Defines an override for loading texture buffers
  80274. * Return true to stop further extensions from loading this texture data
  80275. */
  80276. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80277. /**
  80278. * Defines an override for creating textures
  80279. * Return true to stop further extensions from loading this texture
  80280. */
  80281. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80282. /**
  80283. * Defines an override for loading shader strings
  80284. * Return true to stop further extensions from loading this shader data
  80285. */
  80286. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80287. /**
  80288. * Defines an override for loading materials
  80289. * Return true to stop further extensions from loading this material
  80290. */
  80291. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80292. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80293. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80294. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80295. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80296. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80297. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80298. private static LoadTextureBufferAsync;
  80299. private static CreateTextureAsync;
  80300. private static ApplyExtensions;
  80301. }
  80302. }
  80303. declare module BABYLON.GLTF1 {
  80304. /** @hidden */
  80305. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80306. private _bin;
  80307. constructor();
  80308. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80309. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80310. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80311. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80312. }
  80313. }
  80314. declare module BABYLON.GLTF1 {
  80315. /** @hidden */
  80316. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80317. constructor();
  80318. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80319. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80320. private _loadTexture;
  80321. }
  80322. }
  80323. declare module BABYLON.GLTF2.Loader {
  80324. /**
  80325. * Loader interface with an index field.
  80326. */
  80327. export interface IArrayItem {
  80328. /**
  80329. * The index of this item in the array.
  80330. */
  80331. index: number;
  80332. }
  80333. /**
  80334. * Loader interface with additional members.
  80335. */
  80336. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80337. /** @hidden */
  80338. _data?: Promise<ArrayBufferView>;
  80339. /** @hidden */
  80340. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80341. }
  80342. /**
  80343. * Loader interface with additional members.
  80344. */
  80345. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80346. }
  80347. /** @hidden */
  80348. export interface _IAnimationSamplerData {
  80349. input: Float32Array;
  80350. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80351. output: Float32Array;
  80352. }
  80353. /**
  80354. * Loader interface with additional members.
  80355. */
  80356. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80357. /** @hidden */
  80358. _data?: Promise<_IAnimationSamplerData>;
  80359. }
  80360. /**
  80361. * Loader interface with additional members.
  80362. */
  80363. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80364. channels: IAnimationChannel[];
  80365. samplers: IAnimationSampler[];
  80366. /** @hidden */
  80367. _babylonAnimationGroup?: AnimationGroup;
  80368. }
  80369. /**
  80370. * Loader interface with additional members.
  80371. */
  80372. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80373. /** @hidden */
  80374. _data?: Promise<ArrayBufferView>;
  80375. }
  80376. /**
  80377. * Loader interface with additional members.
  80378. */
  80379. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80380. /** @hidden */
  80381. _data?: Promise<ArrayBufferView>;
  80382. /** @hidden */
  80383. _babylonBuffer?: Promise<Buffer>;
  80384. }
  80385. /**
  80386. * Loader interface with additional members.
  80387. */
  80388. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80389. }
  80390. /**
  80391. * Loader interface with additional members.
  80392. */
  80393. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80394. /** @hidden */
  80395. _data?: Promise<ArrayBufferView>;
  80396. }
  80397. /**
  80398. * Loader interface with additional members.
  80399. */
  80400. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80401. }
  80402. /**
  80403. * Loader interface with additional members.
  80404. */
  80405. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80406. }
  80407. /**
  80408. * Loader interface with additional members.
  80409. */
  80410. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80411. baseColorTexture?: ITextureInfo;
  80412. metallicRoughnessTexture?: ITextureInfo;
  80413. }
  80414. /**
  80415. * Loader interface with additional members.
  80416. */
  80417. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80418. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80419. normalTexture?: IMaterialNormalTextureInfo;
  80420. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80421. emissiveTexture?: ITextureInfo;
  80422. /** @hidden */
  80423. _data?: {
  80424. [babylonDrawMode: number]: {
  80425. babylonMaterial: Material;
  80426. babylonMeshes: AbstractMesh[];
  80427. promise: Promise<void>;
  80428. };
  80429. };
  80430. }
  80431. /**
  80432. * Loader interface with additional members.
  80433. */
  80434. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80435. primitives: IMeshPrimitive[];
  80436. }
  80437. /**
  80438. * Loader interface with additional members.
  80439. */
  80440. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80441. /** @hidden */
  80442. _instanceData?: {
  80443. babylonSourceMesh: Mesh;
  80444. promise: Promise<any>;
  80445. };
  80446. }
  80447. /**
  80448. * Loader interface with additional members.
  80449. */
  80450. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80451. /**
  80452. * The parent glTF node.
  80453. */
  80454. parent?: INode;
  80455. /** @hidden */
  80456. _babylonTransformNode?: TransformNode;
  80457. /** @hidden */
  80458. _primitiveBabylonMeshes?: AbstractMesh[];
  80459. /** @hidden */
  80460. _babylonBones?: Bone[];
  80461. /** @hidden */
  80462. _numMorphTargets?: number;
  80463. }
  80464. /** @hidden */
  80465. export interface _ISamplerData {
  80466. noMipMaps: boolean;
  80467. samplingMode: number;
  80468. wrapU: number;
  80469. wrapV: number;
  80470. }
  80471. /**
  80472. * Loader interface with additional members.
  80473. */
  80474. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80475. /** @hidden */
  80476. _data?: _ISamplerData;
  80477. }
  80478. /**
  80479. * Loader interface with additional members.
  80480. */
  80481. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80482. }
  80483. /**
  80484. * Loader interface with additional members.
  80485. */
  80486. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80487. /** @hidden */
  80488. _data?: {
  80489. babylonSkeleton: Skeleton;
  80490. promise: Promise<void>;
  80491. };
  80492. }
  80493. /**
  80494. * Loader interface with additional members.
  80495. */
  80496. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80497. }
  80498. /**
  80499. * Loader interface with additional members.
  80500. */
  80501. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80502. }
  80503. /**
  80504. * Loader interface with additional members.
  80505. */
  80506. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80507. accessors?: IAccessor[];
  80508. animations?: IAnimation[];
  80509. buffers?: IBuffer[];
  80510. bufferViews?: IBufferView[];
  80511. cameras?: ICamera[];
  80512. images?: IImage[];
  80513. materials?: IMaterial[];
  80514. meshes?: IMesh[];
  80515. nodes?: INode[];
  80516. samplers?: ISampler[];
  80517. scenes?: IScene[];
  80518. skins?: ISkin[];
  80519. textures?: ITexture[];
  80520. }
  80521. }
  80522. declare module BABYLON.GLTF2 {
  80523. /**
  80524. * Interface for a glTF loader extension.
  80525. */
  80526. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80527. /**
  80528. * Called after the loader state changes to LOADING.
  80529. */
  80530. onLoading?(): void;
  80531. /**
  80532. * Called after the loader state changes to READY.
  80533. */
  80534. onReady?(): void;
  80535. /**
  80536. * Define this method to modify the default behavior when loading scenes.
  80537. * @param context The context when loading the asset
  80538. * @param scene The glTF scene property
  80539. * @returns A promise that resolves when the load is complete or null if not handled
  80540. */
  80541. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80542. /**
  80543. * Define this method to modify the default behavior when loading nodes.
  80544. * @param context The context when loading the asset
  80545. * @param node The glTF node property
  80546. * @param assign A function called synchronously after parsing the glTF properties
  80547. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80548. */
  80549. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80550. /**
  80551. * Define this method to modify the default behavior when loading cameras.
  80552. * @param context The context when loading the asset
  80553. * @param camera The glTF camera property
  80554. * @param assign A function called synchronously after parsing the glTF properties
  80555. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80556. */
  80557. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80558. /**
  80559. * @hidden
  80560. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80561. * @param context The context when loading the asset
  80562. * @param primitive The glTF mesh primitive property
  80563. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80564. */
  80565. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80566. /**
  80567. * @hidden
  80568. * Define this method to modify the default behavior when loading data for mesh primitives.
  80569. * @param context The context when loading the asset
  80570. * @param name The mesh name when loading the asset
  80571. * @param node The glTF node when loading the asset
  80572. * @param mesh The glTF mesh when loading the asset
  80573. * @param primitive The glTF mesh primitive property
  80574. * @param assign A function called synchronously after parsing the glTF properties
  80575. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80576. */
  80577. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80578. /**
  80579. * @hidden
  80580. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80581. * @param context The context when loading the asset
  80582. * @param material The glTF material property
  80583. * @param assign A function called synchronously after parsing the glTF properties
  80584. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80585. */
  80586. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80587. /**
  80588. * Define this method to modify the default behavior when creating materials.
  80589. * @param context The context when loading the asset
  80590. * @param material The glTF material property
  80591. * @param babylonDrawMode The draw mode for the Babylon material
  80592. * @returns The Babylon material or null if not handled
  80593. */
  80594. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80595. /**
  80596. * Define this method to modify the default behavior when loading material properties.
  80597. * @param context The context when loading the asset
  80598. * @param material The glTF material property
  80599. * @param babylonMaterial The Babylon material
  80600. * @returns A promise that resolves when the load is complete or null if not handled
  80601. */
  80602. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80603. /**
  80604. * Define this method to modify the default behavior when loading texture infos.
  80605. * @param context The context when loading the asset
  80606. * @param textureInfo The glTF texture info property
  80607. * @param assign A function called synchronously after parsing the glTF properties
  80608. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80609. */
  80610. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80611. /**
  80612. * @hidden
  80613. * Define this method to modify the default behavior when loading textures.
  80614. * @param context The context when loading the asset
  80615. * @param texture The glTF texture property
  80616. * @param assign A function called synchronously after parsing the glTF properties
  80617. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80618. */
  80619. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80620. /**
  80621. * Define this method to modify the default behavior when loading animations.
  80622. * @param context The context when loading the asset
  80623. * @param animation The glTF animation property
  80624. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80625. */
  80626. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80627. /**
  80628. * @hidden
  80629. * Define this method to modify the default behavior when loading skins.
  80630. * @param context The context when loading the asset
  80631. * @param node The glTF node property
  80632. * @param skin The glTF skin property
  80633. * @returns A promise that resolves when the load is complete or null if not handled
  80634. */
  80635. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80636. /**
  80637. * @hidden
  80638. * Define this method to modify the default behavior when loading uris.
  80639. * @param context The context when loading the asset
  80640. * @param property The glTF property associated with the uri
  80641. * @param uri The uri to load
  80642. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80643. */
  80644. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80645. /**
  80646. * Define this method to modify the default behavior when loading buffer views.
  80647. * @param context The context when loading the asset
  80648. * @param bufferView The glTF buffer view property
  80649. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80650. */
  80651. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80652. /**
  80653. * Define this method to modify the default behavior when loading buffers.
  80654. * @param context The context when loading the asset
  80655. * @param buffer The glTF buffer property
  80656. * @param byteOffset The byte offset to load
  80657. * @param byteLength The byte length to load
  80658. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80659. */
  80660. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80661. }
  80662. }
  80663. declare module BABYLON.GLTF2 {
  80664. /**
  80665. * Helper class for working with arrays when loading the glTF asset
  80666. */
  80667. export class ArrayItem {
  80668. /**
  80669. * Gets an item from the given array.
  80670. * @param context The context when loading the asset
  80671. * @param array The array to get the item from
  80672. * @param index The index to the array
  80673. * @returns The array item
  80674. */
  80675. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80676. /**
  80677. * Assign an `index` field to each item of the given array.
  80678. * @param array The array of items
  80679. */
  80680. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80681. }
  80682. /**
  80683. * The glTF 2.0 loader
  80684. */
  80685. export class GLTFLoader implements IGLTFLoader {
  80686. /** @hidden */
  80687. _completePromises: Promise<any>[];
  80688. /** @hidden */
  80689. _forAssetContainer: boolean;
  80690. /** Storage */
  80691. _babylonLights: Light[];
  80692. /** @hidden */
  80693. _disableInstancedMesh: number;
  80694. private _disposed;
  80695. private _parent;
  80696. private _state;
  80697. private _extensions;
  80698. private _rootUrl;
  80699. private _fileName;
  80700. private _uniqueRootUrl;
  80701. private _gltf;
  80702. private _bin;
  80703. private _babylonScene;
  80704. private _rootBabylonMesh;
  80705. private _defaultBabylonMaterialData;
  80706. private static _RegisteredExtensions;
  80707. /**
  80708. * The default glTF sampler.
  80709. */
  80710. static readonly DefaultSampler: ISampler;
  80711. /**
  80712. * Registers a loader extension.
  80713. * @param name The name of the loader extension.
  80714. * @param factory The factory function that creates the loader extension.
  80715. */
  80716. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80717. /**
  80718. * Unregisters a loader extension.
  80719. * @param name The name of the loader extension.
  80720. * @returns A boolean indicating whether the extension has been unregistered
  80721. */
  80722. static UnregisterExtension(name: string): boolean;
  80723. /**
  80724. * The loader state.
  80725. */
  80726. get state(): Nullable<GLTFLoaderState>;
  80727. /**
  80728. * The object that represents the glTF JSON.
  80729. */
  80730. get gltf(): IGLTF;
  80731. /**
  80732. * The BIN chunk of a binary glTF.
  80733. */
  80734. get bin(): Nullable<IDataBuffer>;
  80735. /**
  80736. * The parent file loader.
  80737. */
  80738. get parent(): GLTFFileLoader;
  80739. /**
  80740. * The Babylon scene when loading the asset.
  80741. */
  80742. get babylonScene(): Scene;
  80743. /**
  80744. * The root Babylon mesh when loading the asset.
  80745. */
  80746. get rootBabylonMesh(): Mesh;
  80747. /** @hidden */
  80748. constructor(parent: GLTFFileLoader);
  80749. /** @hidden */
  80750. dispose(): void;
  80751. /** @hidden */
  80752. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80753. /** @hidden */
  80754. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80755. private _loadAsync;
  80756. private _loadData;
  80757. private _setupData;
  80758. private _loadExtensions;
  80759. private _checkExtensions;
  80760. private _setState;
  80761. private _createRootNode;
  80762. /**
  80763. * Loads a glTF scene.
  80764. * @param context The context when loading the asset
  80765. * @param scene The glTF scene property
  80766. * @returns A promise that resolves when the load is complete
  80767. */
  80768. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80769. private _forEachPrimitive;
  80770. private _getMeshes;
  80771. private _getTransformNodes;
  80772. private _getSkeletons;
  80773. private _getAnimationGroups;
  80774. private _startAnimations;
  80775. /**
  80776. * Loads a glTF node.
  80777. * @param context The context when loading the asset
  80778. * @param node The glTF node property
  80779. * @param assign A function called synchronously after parsing the glTF properties
  80780. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80781. */
  80782. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80783. private _loadMeshAsync;
  80784. /**
  80785. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80786. * @param context The context when loading the asset
  80787. * @param name The mesh name when loading the asset
  80788. * @param node The glTF node when loading the asset
  80789. * @param mesh The glTF mesh when loading the asset
  80790. * @param primitive The glTF mesh primitive property
  80791. * @param assign A function called synchronously after parsing the glTF properties
  80792. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80793. */
  80794. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80795. private _loadVertexDataAsync;
  80796. private _createMorphTargets;
  80797. private _loadMorphTargetsAsync;
  80798. private _loadMorphTargetVertexDataAsync;
  80799. private static _LoadTransform;
  80800. private _loadSkinAsync;
  80801. private _loadBones;
  80802. private _loadBone;
  80803. private _loadSkinInverseBindMatricesDataAsync;
  80804. private _updateBoneMatrices;
  80805. private _getNodeMatrix;
  80806. /**
  80807. * Loads a glTF camera.
  80808. * @param context The context when loading the asset
  80809. * @param camera The glTF camera property
  80810. * @param assign A function called synchronously after parsing the glTF properties
  80811. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80812. */
  80813. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80814. private _loadAnimationsAsync;
  80815. /**
  80816. * Loads a glTF animation.
  80817. * @param context The context when loading the asset
  80818. * @param animation The glTF animation property
  80819. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80820. */
  80821. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80822. /**
  80823. * @hidden Loads a glTF animation channel.
  80824. * @param context The context when loading the asset
  80825. * @param animationContext The context of the animation when loading the asset
  80826. * @param animation The glTF animation property
  80827. * @param channel The glTF animation channel property
  80828. * @param babylonAnimationGroup The babylon animation group property
  80829. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80830. * @returns A void promise when the channel load is complete
  80831. */
  80832. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80833. private _loadAnimationSamplerAsync;
  80834. private _loadBufferAsync;
  80835. /**
  80836. * Loads a glTF buffer view.
  80837. * @param context The context when loading the asset
  80838. * @param bufferView The glTF buffer view property
  80839. * @returns A promise that resolves with the loaded data when the load is complete
  80840. */
  80841. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80842. private _loadAccessorAsync;
  80843. /** @hidden */
  80844. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80845. private _loadIndicesAccessorAsync;
  80846. private _loadVertexBufferViewAsync;
  80847. private _loadVertexAccessorAsync;
  80848. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80849. /** @hidden */
  80850. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80851. private _createDefaultMaterial;
  80852. /**
  80853. * Creates a Babylon material from a glTF material.
  80854. * @param context The context when loading the asset
  80855. * @param material The glTF material property
  80856. * @param babylonDrawMode The draw mode for the Babylon material
  80857. * @returns The Babylon material
  80858. */
  80859. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80860. /**
  80861. * Loads properties from a glTF material into a Babylon material.
  80862. * @param context The context when loading the asset
  80863. * @param material The glTF material property
  80864. * @param babylonMaterial The Babylon material
  80865. * @returns A promise that resolves when the load is complete
  80866. */
  80867. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80868. /**
  80869. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80870. * @param context The context when loading the asset
  80871. * @param material The glTF material property
  80872. * @param babylonMaterial The Babylon material
  80873. * @returns A promise that resolves when the load is complete
  80874. */
  80875. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80876. /**
  80877. * Loads the alpha properties from a glTF material into a Babylon material.
  80878. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80879. * @param context The context when loading the asset
  80880. * @param material The glTF material property
  80881. * @param babylonMaterial The Babylon material
  80882. */
  80883. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80884. /**
  80885. * Loads a glTF texture info.
  80886. * @param context The context when loading the asset
  80887. * @param textureInfo The glTF texture info property
  80888. * @param assign A function called synchronously after parsing the glTF properties
  80889. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80890. */
  80891. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80892. /** @hidden */
  80893. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80894. /** @hidden */
  80895. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80896. private _loadSampler;
  80897. /**
  80898. * Loads a glTF image.
  80899. * @param context The context when loading the asset
  80900. * @param image The glTF image property
  80901. * @returns A promise that resolves with the loaded data when the load is complete
  80902. */
  80903. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80904. /**
  80905. * Loads a glTF uri.
  80906. * @param context The context when loading the asset
  80907. * @param property The glTF property associated with the uri
  80908. * @param uri The base64 or relative uri
  80909. * @returns A promise that resolves with the loaded data when the load is complete
  80910. */
  80911. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80912. /**
  80913. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80914. * @param babylonObject the Babylon object with metadata
  80915. * @param pointer the JSON pointer
  80916. */
  80917. static AddPointerMetadata(babylonObject: {
  80918. metadata: any;
  80919. }, pointer: string): void;
  80920. private static _GetTextureWrapMode;
  80921. private static _GetTextureSamplingMode;
  80922. private static _GetTypedArrayConstructor;
  80923. private static _GetTypedArray;
  80924. private static _GetNumComponents;
  80925. private static _ValidateUri;
  80926. /** @hidden */
  80927. static _GetDrawMode(context: string, mode: number | undefined): number;
  80928. private _compileMaterialsAsync;
  80929. private _compileShadowGeneratorsAsync;
  80930. private _forEachExtensions;
  80931. private _applyExtensions;
  80932. private _extensionsOnLoading;
  80933. private _extensionsOnReady;
  80934. private _extensionsLoadSceneAsync;
  80935. private _extensionsLoadNodeAsync;
  80936. private _extensionsLoadCameraAsync;
  80937. private _extensionsLoadVertexDataAsync;
  80938. private _extensionsLoadMeshPrimitiveAsync;
  80939. private _extensionsLoadMaterialAsync;
  80940. private _extensionsCreateMaterial;
  80941. private _extensionsLoadMaterialPropertiesAsync;
  80942. private _extensionsLoadTextureInfoAsync;
  80943. private _extensionsLoadTextureAsync;
  80944. private _extensionsLoadAnimationAsync;
  80945. private _extensionsLoadSkinAsync;
  80946. private _extensionsLoadUriAsync;
  80947. private _extensionsLoadBufferViewAsync;
  80948. private _extensionsLoadBufferAsync;
  80949. /**
  80950. * Helper method called by a loader extension to load an glTF extension.
  80951. * @param context The context when loading the asset
  80952. * @param property The glTF property to load the extension from
  80953. * @param extensionName The name of the extension to load
  80954. * @param actionAsync The action to run
  80955. * @returns The promise returned by actionAsync or null if the extension does not exist
  80956. */
  80957. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80958. /**
  80959. * Helper method called by a loader extension to load a glTF extra.
  80960. * @param context The context when loading the asset
  80961. * @param property The glTF property to load the extra from
  80962. * @param extensionName The name of the extension to load
  80963. * @param actionAsync The action to run
  80964. * @returns The promise returned by actionAsync or null if the extra does not exist
  80965. */
  80966. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80967. /**
  80968. * Checks for presence of an extension.
  80969. * @param name The name of the extension to check
  80970. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80971. */
  80972. isExtensionUsed(name: string): boolean;
  80973. /**
  80974. * Increments the indentation level and logs a message.
  80975. * @param message The message to log
  80976. */
  80977. logOpen(message: string): void;
  80978. /**
  80979. * Decrements the indentation level.
  80980. */
  80981. logClose(): void;
  80982. /**
  80983. * Logs a message
  80984. * @param message The message to log
  80985. */
  80986. log(message: string): void;
  80987. /**
  80988. * Starts a performance counter.
  80989. * @param counterName The name of the performance counter
  80990. */
  80991. startPerformanceCounter(counterName: string): void;
  80992. /**
  80993. * Ends a performance counter.
  80994. * @param counterName The name of the performance counter
  80995. */
  80996. endPerformanceCounter(counterName: string): void;
  80997. }
  80998. }
  80999. declare module BABYLON.GLTF2.Loader.Extensions {
  81000. /** @hidden */
  81001. interface IEXTLightsImageBased_LightImageBased {
  81002. _babylonTexture?: BaseTexture;
  81003. _loaded?: Promise<void>;
  81004. }
  81005. /**
  81006. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81007. */
  81008. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81009. /**
  81010. * The name of this extension.
  81011. */
  81012. readonly name: string;
  81013. /**
  81014. * Defines whether this extension is enabled.
  81015. */
  81016. enabled: boolean;
  81017. private _loader;
  81018. private _lights?;
  81019. /** @hidden */
  81020. constructor(loader: GLTFLoader);
  81021. /** @hidden */
  81022. dispose(): void;
  81023. /** @hidden */
  81024. onLoading(): void;
  81025. /** @hidden */
  81026. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81027. private _loadLightAsync;
  81028. }
  81029. }
  81030. declare module BABYLON.GLTF2.Loader.Extensions {
  81031. /**
  81032. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81033. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81034. * !!! Experimental Extension Subject to Changes !!!
  81035. */
  81036. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81037. /**
  81038. * The name of this extension.
  81039. */
  81040. readonly name: string;
  81041. /**
  81042. * Defines whether this extension is enabled.
  81043. */
  81044. enabled: boolean;
  81045. private _loader;
  81046. /** @hidden */
  81047. constructor(loader: GLTFLoader);
  81048. /** @hidden */
  81049. dispose(): void;
  81050. /** @hidden */
  81051. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81052. }
  81053. }
  81054. declare module BABYLON.GLTF2.Loader.Extensions {
  81055. /**
  81056. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81057. */
  81058. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81059. /**
  81060. * The name of this extension.
  81061. */
  81062. readonly name: string;
  81063. /**
  81064. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81065. */
  81066. dracoCompression?: DracoCompression;
  81067. /**
  81068. * Defines whether this extension is enabled.
  81069. */
  81070. enabled: boolean;
  81071. private _loader;
  81072. /** @hidden */
  81073. constructor(loader: GLTFLoader);
  81074. /** @hidden */
  81075. dispose(): void;
  81076. /** @hidden */
  81077. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81078. }
  81079. }
  81080. declare module BABYLON.GLTF2.Loader.Extensions {
  81081. /**
  81082. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81083. */
  81084. export class KHR_lights implements IGLTFLoaderExtension {
  81085. /**
  81086. * The name of this extension.
  81087. */
  81088. readonly name: string;
  81089. /**
  81090. * Defines whether this extension is enabled.
  81091. */
  81092. enabled: boolean;
  81093. private _loader;
  81094. private _lights?;
  81095. /** @hidden */
  81096. constructor(loader: GLTFLoader);
  81097. /** @hidden */
  81098. dispose(): void;
  81099. /** @hidden */
  81100. onLoading(): void;
  81101. /** @hidden */
  81102. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81103. }
  81104. }
  81105. declare module BABYLON.GLTF2.Loader.Extensions {
  81106. /**
  81107. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81108. */
  81109. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81110. /**
  81111. * The name of this extension.
  81112. */
  81113. readonly name: string;
  81114. /**
  81115. * Defines whether this extension is enabled.
  81116. */
  81117. enabled: boolean;
  81118. /**
  81119. * Defines a number that determines the order the extensions are applied.
  81120. */
  81121. order: number;
  81122. private _loader;
  81123. /** @hidden */
  81124. constructor(loader: GLTFLoader);
  81125. /** @hidden */
  81126. dispose(): void;
  81127. /** @hidden */
  81128. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81129. private _loadSpecularGlossinessPropertiesAsync;
  81130. }
  81131. }
  81132. declare module BABYLON.GLTF2.Loader.Extensions {
  81133. /**
  81134. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81135. */
  81136. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81137. /**
  81138. * The name of this extension.
  81139. */
  81140. readonly name: string;
  81141. /**
  81142. * Defines whether this extension is enabled.
  81143. */
  81144. enabled: boolean;
  81145. /**
  81146. * Defines a number that determines the order the extensions are applied.
  81147. */
  81148. order: number;
  81149. private _loader;
  81150. /** @hidden */
  81151. constructor(loader: GLTFLoader);
  81152. /** @hidden */
  81153. dispose(): void;
  81154. /** @hidden */
  81155. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81156. private _loadUnlitPropertiesAsync;
  81157. }
  81158. }
  81159. declare module BABYLON.GLTF2.Loader.Extensions {
  81160. /**
  81161. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81162. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81163. * !!! Experimental Extension Subject to Changes !!!
  81164. */
  81165. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81166. /**
  81167. * The name of this extension.
  81168. */
  81169. readonly name: string;
  81170. /**
  81171. * Defines whether this extension is enabled.
  81172. */
  81173. enabled: boolean;
  81174. /**
  81175. * Defines a number that determines the order the extensions are applied.
  81176. */
  81177. order: number;
  81178. private _loader;
  81179. /** @hidden */
  81180. constructor(loader: GLTFLoader);
  81181. /** @hidden */
  81182. dispose(): void;
  81183. /** @hidden */
  81184. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81185. private _loadClearCoatPropertiesAsync;
  81186. }
  81187. }
  81188. declare module BABYLON.GLTF2.Loader.Extensions {
  81189. /**
  81190. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81191. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81192. * !!! Experimental Extension Subject to Changes !!!
  81193. */
  81194. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81195. /**
  81196. * The name of this extension.
  81197. */
  81198. readonly name: string;
  81199. /**
  81200. * Defines whether this extension is enabled.
  81201. */
  81202. enabled: boolean;
  81203. /**
  81204. * Defines a number that determines the order the extensions are applied.
  81205. */
  81206. order: number;
  81207. private _loader;
  81208. /** @hidden */
  81209. constructor(loader: GLTFLoader);
  81210. /** @hidden */
  81211. dispose(): void;
  81212. /** @hidden */
  81213. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81214. private _loadSheenPropertiesAsync;
  81215. }
  81216. }
  81217. declare module BABYLON.GLTF2.Loader.Extensions {
  81218. /**
  81219. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81220. * !!! Experimental Extension Subject to Changes !!!
  81221. */
  81222. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81223. /**
  81224. * The name of this extension.
  81225. */
  81226. readonly name: string;
  81227. /**
  81228. * Defines whether this extension is enabled.
  81229. */
  81230. enabled: boolean;
  81231. /**
  81232. * Defines a number that determines the order the extensions are applied.
  81233. */
  81234. order: number;
  81235. private _loader;
  81236. /** @hidden */
  81237. constructor(loader: GLTFLoader);
  81238. /** @hidden */
  81239. dispose(): void;
  81240. /** @hidden */
  81241. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81242. private _loadSpecularPropertiesAsync;
  81243. }
  81244. }
  81245. declare module BABYLON.GLTF2.Loader.Extensions {
  81246. /**
  81247. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81248. * !!! Experimental Extension Subject to Changes !!!
  81249. */
  81250. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81251. /**
  81252. * Default ior Value from the spec.
  81253. */
  81254. private static readonly _DEFAULT_IOR;
  81255. /**
  81256. * The name of this extension.
  81257. */
  81258. readonly name: string;
  81259. /**
  81260. * Defines whether this extension is enabled.
  81261. */
  81262. enabled: boolean;
  81263. /**
  81264. * Defines a number that determines the order the extensions are applied.
  81265. */
  81266. order: number;
  81267. private _loader;
  81268. /** @hidden */
  81269. constructor(loader: GLTFLoader);
  81270. /** @hidden */
  81271. dispose(): void;
  81272. /** @hidden */
  81273. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81274. private _loadIorPropertiesAsync;
  81275. }
  81276. }
  81277. declare module BABYLON.GLTF2.Loader.Extensions {
  81278. /**
  81279. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81280. * !!! Experimental Extension Subject to Changes !!!
  81281. */
  81282. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81283. /**
  81284. * The name of this extension.
  81285. */
  81286. readonly name: string;
  81287. /**
  81288. * Defines whether this extension is enabled.
  81289. */
  81290. enabled: boolean;
  81291. private _loader;
  81292. /** @hidden */
  81293. constructor(loader: GLTFLoader);
  81294. /** @hidden */
  81295. dispose(): void;
  81296. /**
  81297. * Gets the list of available variant names for this asset.
  81298. * @param rootMesh The glTF root mesh
  81299. * @returns the list of all the variant names for this model
  81300. */
  81301. static GetAvailableVariants(rootMesh: Mesh): string[];
  81302. /**
  81303. * Gets the list of available variant names for this asset.
  81304. * @param rootMesh The glTF root mesh
  81305. * @returns the list of all the variant names for this model
  81306. */
  81307. getAvailableVariants(rootMesh: Mesh): string[];
  81308. /**
  81309. * Select a variant given a variant name or a list of variant names.
  81310. * @param rootMesh The glTF root mesh
  81311. * @param variantName The variant name(s) to select.
  81312. */
  81313. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81314. /**
  81315. * Select a variant given a variant name or a list of variant names.
  81316. * @param rootMesh The glTF root mesh
  81317. * @param variantName The variant name(s) to select.
  81318. */
  81319. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81320. /**
  81321. * Reset back to the original before selecting a variant.
  81322. * @param rootMesh The glTF root mesh
  81323. */
  81324. static Reset(rootMesh: Mesh): void;
  81325. /**
  81326. * Reset back to the original before selecting a variant.
  81327. * @param rootMesh The glTF root mesh
  81328. */
  81329. reset(rootMesh: Mesh): void;
  81330. /**
  81331. * Gets the last selected variant name(s) or null if original.
  81332. * @param rootMesh The glTF root mesh
  81333. * @returns The selected variant name(s).
  81334. */
  81335. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81336. /**
  81337. * Gets the last selected variant name(s) or null if original.
  81338. * @param rootMesh The glTF root mesh
  81339. * @returns The selected variant name(s).
  81340. */
  81341. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81342. private static _GetExtensionMetadata;
  81343. /** @hidden */
  81344. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81345. }
  81346. }
  81347. declare module BABYLON.GLTF2.Loader.Extensions {
  81348. /**
  81349. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81350. * !!! Experimental Extension Subject to Changes !!!
  81351. */
  81352. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81353. /**
  81354. * The name of this extension.
  81355. */
  81356. readonly name: string;
  81357. /**
  81358. * Defines whether this extension is enabled.
  81359. */
  81360. enabled: boolean;
  81361. /**
  81362. * Defines a number that determines the order the extensions are applied.
  81363. */
  81364. order: number;
  81365. private _loader;
  81366. /** @hidden */
  81367. constructor(loader: GLTFLoader);
  81368. /** @hidden */
  81369. dispose(): void;
  81370. /** @hidden */
  81371. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81372. private _loadTransparentPropertiesAsync;
  81373. }
  81374. }
  81375. declare module BABYLON.GLTF2.Loader.Extensions {
  81376. /**
  81377. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81378. */
  81379. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81380. /**
  81381. * The name of this extension.
  81382. */
  81383. readonly name: string;
  81384. /**
  81385. * Defines whether this extension is enabled.
  81386. */
  81387. enabled: boolean;
  81388. /** @hidden */
  81389. constructor(loader: GLTFLoader);
  81390. /** @hidden */
  81391. dispose(): void;
  81392. }
  81393. }
  81394. declare module BABYLON.GLTF2.Loader.Extensions {
  81395. /**
  81396. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81397. * !!! Experimental Extension Subject to Changes !!!
  81398. */
  81399. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81400. /** The name of this extension. */
  81401. readonly name: string;
  81402. /** Defines whether this extension is enabled. */
  81403. enabled: boolean;
  81404. private _loader;
  81405. /** @hidden */
  81406. constructor(loader: GLTFLoader);
  81407. /** @hidden */
  81408. dispose(): void;
  81409. /** @hidden */
  81410. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81411. }
  81412. }
  81413. declare module BABYLON.GLTF2.Loader.Extensions {
  81414. /**
  81415. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81416. */
  81417. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81418. /**
  81419. * The name of this extension.
  81420. */
  81421. readonly name: string;
  81422. /**
  81423. * Defines whether this extension is enabled.
  81424. */
  81425. enabled: boolean;
  81426. private _loader;
  81427. /** @hidden */
  81428. constructor(loader: GLTFLoader);
  81429. /** @hidden */
  81430. dispose(): void;
  81431. /** @hidden */
  81432. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81433. }
  81434. }
  81435. declare module BABYLON.GLTF2.Loader.Extensions {
  81436. /**
  81437. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81438. * !!! Experimental Extension Subject to Changes !!!
  81439. */
  81440. export class KHR_xmp implements IGLTFLoaderExtension {
  81441. /**
  81442. * The name of this extension.
  81443. */
  81444. readonly name: string;
  81445. /**
  81446. * Defines whether this extension is enabled.
  81447. */
  81448. enabled: boolean;
  81449. /**
  81450. * Defines a number that determines the order the extensions are applied.
  81451. */
  81452. order: number;
  81453. private _loader;
  81454. /** @hidden */
  81455. constructor(loader: GLTFLoader);
  81456. /** @hidden */
  81457. dispose(): void;
  81458. /**
  81459. * Called after the loader state changes to LOADING.
  81460. */
  81461. onLoading(): void;
  81462. }
  81463. }
  81464. declare module BABYLON.GLTF2.Loader.Extensions {
  81465. /**
  81466. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81467. */
  81468. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81469. /**
  81470. * The name of this extension.
  81471. */
  81472. readonly name: string;
  81473. /**
  81474. * Defines whether this extension is enabled.
  81475. */
  81476. enabled: boolean;
  81477. private _loader;
  81478. private _clips;
  81479. private _emitters;
  81480. /** @hidden */
  81481. constructor(loader: GLTFLoader);
  81482. /** @hidden */
  81483. dispose(): void;
  81484. /** @hidden */
  81485. onLoading(): void;
  81486. /** @hidden */
  81487. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81488. /** @hidden */
  81489. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81490. /** @hidden */
  81491. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81492. private _loadClipAsync;
  81493. private _loadEmitterAsync;
  81494. private _getEventAction;
  81495. private _loadAnimationEventAsync;
  81496. }
  81497. }
  81498. declare module BABYLON.GLTF2.Loader.Extensions {
  81499. /**
  81500. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81501. */
  81502. export class MSFT_lod implements IGLTFLoaderExtension {
  81503. /**
  81504. * The name of this extension.
  81505. */
  81506. readonly name: string;
  81507. /**
  81508. * Defines whether this extension is enabled.
  81509. */
  81510. enabled: boolean;
  81511. /**
  81512. * Defines a number that determines the order the extensions are applied.
  81513. */
  81514. order: number;
  81515. /**
  81516. * Maximum number of LODs to load, starting from the lowest LOD.
  81517. */
  81518. maxLODsToLoad: number;
  81519. /**
  81520. * Observable raised when all node LODs of one level are loaded.
  81521. * The event data is the index of the loaded LOD starting from zero.
  81522. * Dispose the loader to cancel the loading of the next level of LODs.
  81523. */
  81524. onNodeLODsLoadedObservable: Observable<number>;
  81525. /**
  81526. * Observable raised when all material LODs of one level are loaded.
  81527. * The event data is the index of the loaded LOD starting from zero.
  81528. * Dispose the loader to cancel the loading of the next level of LODs.
  81529. */
  81530. onMaterialLODsLoadedObservable: Observable<number>;
  81531. private _loader;
  81532. private _bufferLODs;
  81533. private _nodeIndexLOD;
  81534. private _nodeSignalLODs;
  81535. private _nodePromiseLODs;
  81536. private _nodeBufferLODs;
  81537. private _materialIndexLOD;
  81538. private _materialSignalLODs;
  81539. private _materialPromiseLODs;
  81540. private _materialBufferLODs;
  81541. /** @hidden */
  81542. constructor(loader: GLTFLoader);
  81543. /** @hidden */
  81544. dispose(): void;
  81545. /** @hidden */
  81546. onReady(): void;
  81547. /** @hidden */
  81548. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81549. /** @hidden */
  81550. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81551. /** @hidden */
  81552. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81553. /** @hidden */
  81554. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81555. /** @hidden */
  81556. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81557. private _loadBufferLOD;
  81558. /**
  81559. * Gets an array of LOD properties from lowest to highest.
  81560. */
  81561. private _getLODs;
  81562. private _disposeTransformNode;
  81563. private _disposeMaterials;
  81564. }
  81565. }
  81566. declare module BABYLON.GLTF2.Loader.Extensions {
  81567. /** @hidden */
  81568. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81569. readonly name: string;
  81570. enabled: boolean;
  81571. private _loader;
  81572. constructor(loader: GLTFLoader);
  81573. dispose(): void;
  81574. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81575. }
  81576. }
  81577. declare module BABYLON.GLTF2.Loader.Extensions {
  81578. /** @hidden */
  81579. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81580. readonly name: string;
  81581. enabled: boolean;
  81582. private _loader;
  81583. constructor(loader: GLTFLoader);
  81584. dispose(): void;
  81585. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81586. }
  81587. }
  81588. declare module BABYLON.GLTF2.Loader.Extensions {
  81589. /**
  81590. * Store glTF extras (if present) in BJS objects' metadata
  81591. */
  81592. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81593. /**
  81594. * The name of this extension.
  81595. */
  81596. readonly name: string;
  81597. /**
  81598. * Defines whether this extension is enabled.
  81599. */
  81600. enabled: boolean;
  81601. private _loader;
  81602. private _assignExtras;
  81603. /** @hidden */
  81604. constructor(loader: GLTFLoader);
  81605. /** @hidden */
  81606. dispose(): void;
  81607. /** @hidden */
  81608. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81609. /** @hidden */
  81610. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81611. /** @hidden */
  81612. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81613. }
  81614. }
  81615. declare module BABYLON {
  81616. /**
  81617. * Class reading and parsing the MTL file bundled with the obj file.
  81618. */
  81619. export class MTLFileLoader {
  81620. /**
  81621. * Invert Y-Axis of referenced textures on load
  81622. */
  81623. static INVERT_TEXTURE_Y: boolean;
  81624. /**
  81625. * All material loaded from the mtl will be set here
  81626. */
  81627. materials: StandardMaterial[];
  81628. /**
  81629. * This function will read the mtl file and create each material described inside
  81630. * This function could be improve by adding :
  81631. * -some component missing (Ni, Tf...)
  81632. * -including the specific options available
  81633. *
  81634. * @param scene defines the scene the material will be created in
  81635. * @param data defines the mtl data to parse
  81636. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81637. * @param forAssetContainer defines if the material should be registered in the scene
  81638. */
  81639. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81640. /**
  81641. * Gets the texture for the material.
  81642. *
  81643. * If the material is imported from input file,
  81644. * We sanitize the url to ensure it takes the textre from aside the material.
  81645. *
  81646. * @param rootUrl The root url to load from
  81647. * @param value The value stored in the mtl
  81648. * @return The Texture
  81649. */
  81650. private static _getTexture;
  81651. }
  81652. }
  81653. declare module BABYLON {
  81654. /**
  81655. * Options for loading OBJ/MTL files
  81656. */
  81657. type MeshLoadOptions = {
  81658. /**
  81659. * Defines if UVs are optimized by default during load.
  81660. */
  81661. OptimizeWithUV: boolean;
  81662. /**
  81663. * Defines custom scaling of UV coordinates of loaded meshes.
  81664. */
  81665. UVScaling: Vector2;
  81666. /**
  81667. * Invert model on y-axis (does a model scaling inversion)
  81668. */
  81669. InvertY: boolean;
  81670. /**
  81671. * Invert Y-Axis of referenced textures on load
  81672. */
  81673. InvertTextureY: boolean;
  81674. /**
  81675. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81676. */
  81677. ImportVertexColors: boolean;
  81678. /**
  81679. * Compute the normals for the model, even if normals are present in the file.
  81680. */
  81681. ComputeNormals: boolean;
  81682. /**
  81683. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81684. */
  81685. SkipMaterials: boolean;
  81686. /**
  81687. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81688. */
  81689. MaterialLoadingFailsSilently: boolean;
  81690. };
  81691. /**
  81692. * OBJ file type loader.
  81693. * This is a babylon scene loader plugin.
  81694. */
  81695. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81696. /**
  81697. * Defines if UVs are optimized by default during load.
  81698. */
  81699. static OPTIMIZE_WITH_UV: boolean;
  81700. /**
  81701. * Invert model on y-axis (does a model scaling inversion)
  81702. */
  81703. static INVERT_Y: boolean;
  81704. /**
  81705. * Invert Y-Axis of referenced textures on load
  81706. */
  81707. static get INVERT_TEXTURE_Y(): boolean;
  81708. static set INVERT_TEXTURE_Y(value: boolean);
  81709. /**
  81710. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81711. */
  81712. static IMPORT_VERTEX_COLORS: boolean;
  81713. /**
  81714. * Compute the normals for the model, even if normals are present in the file.
  81715. */
  81716. static COMPUTE_NORMALS: boolean;
  81717. /**
  81718. * Defines custom scaling of UV coordinates of loaded meshes.
  81719. */
  81720. static UV_SCALING: Vector2;
  81721. /**
  81722. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81723. */
  81724. static SKIP_MATERIALS: boolean;
  81725. /**
  81726. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81727. *
  81728. * Defaults to true for backwards compatibility.
  81729. */
  81730. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81731. /**
  81732. * Defines the name of the plugin.
  81733. */
  81734. name: string;
  81735. /**
  81736. * Defines the extension the plugin is able to load.
  81737. */
  81738. extensions: string;
  81739. /** @hidden */
  81740. obj: RegExp;
  81741. /** @hidden */
  81742. group: RegExp;
  81743. /** @hidden */
  81744. mtllib: RegExp;
  81745. /** @hidden */
  81746. usemtl: RegExp;
  81747. /** @hidden */
  81748. smooth: RegExp;
  81749. /** @hidden */
  81750. vertexPattern: RegExp;
  81751. /** @hidden */
  81752. normalPattern: RegExp;
  81753. /** @hidden */
  81754. uvPattern: RegExp;
  81755. /** @hidden */
  81756. facePattern1: RegExp;
  81757. /** @hidden */
  81758. facePattern2: RegExp;
  81759. /** @hidden */
  81760. facePattern3: RegExp;
  81761. /** @hidden */
  81762. facePattern4: RegExp;
  81763. /** @hidden */
  81764. facePattern5: RegExp;
  81765. private _forAssetContainer;
  81766. private _meshLoadOptions;
  81767. /**
  81768. * Creates loader for .OBJ files
  81769. *
  81770. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81771. */
  81772. constructor(meshLoadOptions?: MeshLoadOptions);
  81773. private static get currentMeshLoadOptions();
  81774. /**
  81775. * Calls synchronously the MTL file attached to this obj.
  81776. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81777. * Without this function materials are not displayed in the first frame (but displayed after).
  81778. * In consequence it is impossible to get material information in your HTML file
  81779. *
  81780. * @param url The URL of the MTL file
  81781. * @param rootUrl
  81782. * @param onSuccess Callback function to be called when the MTL file is loaded
  81783. * @private
  81784. */
  81785. private _loadMTL;
  81786. /**
  81787. * Instantiates a OBJ file loader plugin.
  81788. * @returns the created plugin
  81789. */
  81790. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81791. /**
  81792. * If the data string can be loaded directly.
  81793. *
  81794. * @param data string containing the file data
  81795. * @returns if the data can be loaded directly
  81796. */
  81797. canDirectLoad(data: string): boolean;
  81798. /**
  81799. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81800. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81801. * @param scene the scene the meshes should be added to
  81802. * @param data the OBJ data to load
  81803. * @param rootUrl root url to load from
  81804. * @param onProgress event that fires when loading progress has occured
  81805. * @param fileName Defines the name of the file to load
  81806. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81807. */
  81808. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81809. meshes: AbstractMesh[];
  81810. particleSystems: IParticleSystem[];
  81811. skeletons: Skeleton[];
  81812. animationGroups: AnimationGroup[];
  81813. }>;
  81814. /**
  81815. * Imports all objects from the loaded OBJ data and adds them to the scene
  81816. * @param scene the scene the objects should be added to
  81817. * @param data the OBJ data to load
  81818. * @param rootUrl root url to load from
  81819. * @param onProgress event that fires when loading progress has occured
  81820. * @param fileName Defines the name of the file to load
  81821. * @returns a promise which completes when objects have been loaded to the scene
  81822. */
  81823. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81824. /**
  81825. * Load into an asset container.
  81826. * @param scene The scene to load into
  81827. * @param data The data to import
  81828. * @param rootUrl The root url for scene and resources
  81829. * @param onProgress The callback when the load progresses
  81830. * @param fileName Defines the name of the file to load
  81831. * @returns The loaded asset container
  81832. */
  81833. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81834. /**
  81835. * Read the OBJ file and create an Array of meshes.
  81836. * Each mesh contains all information given by the OBJ and the MTL file.
  81837. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81838. *
  81839. * @param meshesNames
  81840. * @param scene Scene The scene where are displayed the data
  81841. * @param data String The content of the obj file
  81842. * @param rootUrl String The path to the folder
  81843. * @returns Array<AbstractMesh>
  81844. * @private
  81845. */
  81846. private _parseSolid;
  81847. }
  81848. }
  81849. declare module BABYLON {
  81850. /**
  81851. * STL file type loader.
  81852. * This is a babylon scene loader plugin.
  81853. */
  81854. export class STLFileLoader implements ISceneLoaderPlugin {
  81855. /** @hidden */
  81856. solidPattern: RegExp;
  81857. /** @hidden */
  81858. facetsPattern: RegExp;
  81859. /** @hidden */
  81860. normalPattern: RegExp;
  81861. /** @hidden */
  81862. vertexPattern: RegExp;
  81863. /**
  81864. * Defines the name of the plugin.
  81865. */
  81866. name: string;
  81867. /**
  81868. * Defines the extensions the stl loader is able to load.
  81869. * force data to come in as an ArrayBuffer
  81870. * we'll convert to string if it looks like it's an ASCII .stl
  81871. */
  81872. extensions: ISceneLoaderPluginExtensions;
  81873. /**
  81874. * Import meshes into a scene.
  81875. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81876. * @param scene The scene to import into
  81877. * @param data The data to import
  81878. * @param rootUrl The root url for scene and resources
  81879. * @param meshes The meshes array to import into
  81880. * @param particleSystems The particle systems array to import into
  81881. * @param skeletons The skeletons array to import into
  81882. * @param onError The callback when import fails
  81883. * @returns True if successful or false otherwise
  81884. */
  81885. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81886. /**
  81887. * Load into a scene.
  81888. * @param scene The scene to load into
  81889. * @param data The data to import
  81890. * @param rootUrl The root url for scene and resources
  81891. * @param onError The callback when import fails
  81892. * @returns true if successful or false otherwise
  81893. */
  81894. load(scene: Scene, data: any, rootUrl: string): boolean;
  81895. /**
  81896. * Load into an asset container.
  81897. * @param scene The scene to load into
  81898. * @param data The data to import
  81899. * @param rootUrl The root url for scene and resources
  81900. * @param onError The callback when import fails
  81901. * @returns The loaded asset container
  81902. */
  81903. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81904. private _isBinary;
  81905. private _parseBinary;
  81906. private _parseASCII;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /**
  81911. * Class for generating OBJ data from a Babylon scene.
  81912. */
  81913. export class OBJExport {
  81914. /**
  81915. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81916. * @param mesh defines the list of meshes to serialize
  81917. * @param materials defines if materials should be exported
  81918. * @param matlibname defines the name of the associated mtl file
  81919. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81920. * @returns the OBJ content
  81921. */
  81922. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81923. /**
  81924. * Exports the material(s) of a mesh in .MTL file format (text)
  81925. * @param mesh defines the mesh to extract the material from
  81926. * @returns the mtl content
  81927. */
  81928. static MTL(mesh: Mesh): string;
  81929. }
  81930. }
  81931. declare module BABYLON {
  81932. /** @hidden */
  81933. export var __IGLTFExporterExtension: number;
  81934. /**
  81935. * Interface for extending the exporter
  81936. * @hidden
  81937. */
  81938. export interface IGLTFExporterExtension {
  81939. /**
  81940. * The name of this extension
  81941. */
  81942. readonly name: string;
  81943. /**
  81944. * Defines whether this extension is enabled
  81945. */
  81946. enabled: boolean;
  81947. /**
  81948. * Defines whether this extension is required
  81949. */
  81950. required: boolean;
  81951. }
  81952. }
  81953. declare module BABYLON.GLTF2.Exporter {
  81954. /** @hidden */
  81955. export var __IGLTFExporterExtensionV2: number;
  81956. /**
  81957. * Interface for a glTF exporter extension
  81958. * @hidden
  81959. */
  81960. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81961. /**
  81962. * Define this method to modify the default behavior before exporting a texture
  81963. * @param context The context when loading the asset
  81964. * @param babylonTexture The Babylon.js texture
  81965. * @param mimeType The mime-type of the generated image
  81966. * @returns A promise that resolves with the exported texture
  81967. */
  81968. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81969. /**
  81970. * Define this method to get notified when a texture info is created
  81971. * @param context The context when loading the asset
  81972. * @param textureInfo The glTF texture info
  81973. * @param babylonTexture The Babylon.js texture
  81974. */
  81975. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81976. /**
  81977. * Define this method to modify the default behavior when exporting texture info
  81978. * @param context The context when loading the asset
  81979. * @param meshPrimitive glTF mesh primitive
  81980. * @param babylonSubMesh Babylon submesh
  81981. * @param binaryWriter glTF serializer binary writer instance
  81982. * @returns nullable IMeshPrimitive promise
  81983. */
  81984. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81985. /**
  81986. * Define this method to modify the default behavior when exporting a node
  81987. * @param context The context when exporting the node
  81988. * @param node glTF node
  81989. * @param babylonNode BabylonJS node
  81990. * @returns nullable INode promise
  81991. */
  81992. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81993. [key: number]: number;
  81994. }): Promise<Nullable<INode>>;
  81995. /**
  81996. * Define this method to modify the default behavior when exporting a material
  81997. * @param material glTF material
  81998. * @param babylonMaterial BabylonJS material
  81999. * @returns nullable IMaterial promise
  82000. */
  82001. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82002. /**
  82003. * Define this method to return additional textures to export from a material
  82004. * @param material glTF material
  82005. * @param babylonMaterial BabylonJS material
  82006. * @returns List of textures
  82007. */
  82008. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82009. /** Gets a boolean indicating that this extension was used */
  82010. wasUsed: boolean;
  82011. /** Gets a boolean indicating that this extension is required for the file to work */
  82012. required: boolean;
  82013. /**
  82014. * Called after the exporter state changes to EXPORTING
  82015. */
  82016. onExporting?(): void;
  82017. }
  82018. }
  82019. declare module BABYLON.GLTF2.Exporter {
  82020. /**
  82021. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82022. * @hidden
  82023. */
  82024. export class _GLTFMaterialExporter {
  82025. /**
  82026. * Represents the dielectric specular values for R, G and B
  82027. */
  82028. private static readonly _DielectricSpecular;
  82029. /**
  82030. * Allows the maximum specular power to be defined for material calculations
  82031. */
  82032. private static readonly _MaxSpecularPower;
  82033. /**
  82034. * Mapping to store textures
  82035. */
  82036. private _textureMap;
  82037. /**
  82038. * Numeric tolerance value
  82039. */
  82040. private static readonly _Epsilon;
  82041. /**
  82042. * Reference to the glTF Exporter
  82043. */
  82044. private _exporter;
  82045. constructor(exporter: _Exporter);
  82046. /**
  82047. * Specifies if two colors are approximately equal in value
  82048. * @param color1 first color to compare to
  82049. * @param color2 second color to compare to
  82050. * @param epsilon threshold value
  82051. */
  82052. private static FuzzyEquals;
  82053. /**
  82054. * Gets the materials from a Babylon scene and converts them to glTF materials
  82055. * @param scene babylonjs scene
  82056. * @param mimeType texture mime type
  82057. * @param images array of images
  82058. * @param textures array of textures
  82059. * @param materials array of materials
  82060. * @param imageData mapping of texture names to base64 textures
  82061. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82062. */
  82063. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82064. /**
  82065. * Makes a copy of the glTF material without the texture parameters
  82066. * @param originalMaterial original glTF material
  82067. * @returns glTF material without texture parameters
  82068. */
  82069. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82070. /**
  82071. * Specifies if the material has any texture parameters present
  82072. * @param material glTF Material
  82073. * @returns boolean specifying if texture parameters are present
  82074. */
  82075. _hasTexturesPresent(material: IMaterial): boolean;
  82076. /**
  82077. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82078. * @param babylonStandardMaterial
  82079. * @returns glTF Metallic Roughness Material representation
  82080. */
  82081. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82082. /**
  82083. * Computes the metallic factor
  82084. * @param diffuse diffused value
  82085. * @param specular specular value
  82086. * @param oneMinusSpecularStrength one minus the specular strength
  82087. * @returns metallic value
  82088. */
  82089. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82090. /**
  82091. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82092. * @param glTFMaterial glTF material
  82093. * @param babylonMaterial Babylon material
  82094. */
  82095. private static _SetAlphaMode;
  82096. /**
  82097. * Converts a Babylon Standard Material to a glTF Material
  82098. * @param babylonStandardMaterial BJS Standard Material
  82099. * @param mimeType mime type to use for the textures
  82100. * @param images array of glTF image interfaces
  82101. * @param textures array of glTF texture interfaces
  82102. * @param materials array of glTF material interfaces
  82103. * @param imageData map of image file name to data
  82104. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82105. */
  82106. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82107. private _finishMaterial;
  82108. /**
  82109. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82110. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82111. * @param mimeType mime type to use for the textures
  82112. * @param images array of glTF image interfaces
  82113. * @param textures array of glTF texture interfaces
  82114. * @param materials array of glTF material interfaces
  82115. * @param imageData map of image file name to data
  82116. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82117. */
  82118. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82119. /**
  82120. * Converts an image typed array buffer to a base64 image
  82121. * @param buffer typed array buffer
  82122. * @param width width of the image
  82123. * @param height height of the image
  82124. * @param mimeType mimetype of the image
  82125. * @returns base64 image string
  82126. */
  82127. private _createBase64FromCanvasAsync;
  82128. /**
  82129. * Generates a white texture based on the specified width and height
  82130. * @param width width of the texture in pixels
  82131. * @param height height of the texture in pixels
  82132. * @param scene babylonjs scene
  82133. * @returns white texture
  82134. */
  82135. private _createWhiteTexture;
  82136. /**
  82137. * 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
  82138. * @param texture1 first texture to resize
  82139. * @param texture2 second texture to resize
  82140. * @param scene babylonjs scene
  82141. * @returns resized textures or null
  82142. */
  82143. private _resizeTexturesToSameDimensions;
  82144. /**
  82145. * Converts an array of pixels to a Float32Array
  82146. * Throws an error if the pixel format is not supported
  82147. * @param pixels - array buffer containing pixel values
  82148. * @returns Float32 of pixels
  82149. */
  82150. private _convertPixelArrayToFloat32;
  82151. /**
  82152. * Convert Specular Glossiness Textures to Metallic Roughness
  82153. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82154. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82155. * @param diffuseTexture texture used to store diffuse information
  82156. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82157. * @param factors specular glossiness material factors
  82158. * @param mimeType the mime type to use for the texture
  82159. * @returns pbr metallic roughness interface or null
  82160. */
  82161. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82162. /**
  82163. * Converts specular glossiness material properties to metallic roughness
  82164. * @param specularGlossiness interface with specular glossiness material properties
  82165. * @returns interface with metallic roughness material properties
  82166. */
  82167. private _convertSpecularGlossinessToMetallicRoughness;
  82168. /**
  82169. * Calculates the surface reflectance, independent of lighting conditions
  82170. * @param color Color source to calculate brightness from
  82171. * @returns number representing the perceived brightness, or zero if color is undefined
  82172. */
  82173. private _getPerceivedBrightness;
  82174. /**
  82175. * Returns the maximum color component value
  82176. * @param color
  82177. * @returns maximum color component value, or zero if color is null or undefined
  82178. */
  82179. private _getMaxComponent;
  82180. /**
  82181. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82182. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82183. * @param mimeType mime type to use for the textures
  82184. * @param images array of glTF image interfaces
  82185. * @param textures array of glTF texture interfaces
  82186. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82187. * @param imageData map of image file name to data
  82188. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82189. * @returns glTF PBR Metallic Roughness factors
  82190. */
  82191. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82192. private _getGLTFTextureSampler;
  82193. private _getGLTFTextureWrapMode;
  82194. private _getGLTFTextureWrapModesSampler;
  82195. /**
  82196. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82197. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82198. * @param mimeType mime type to use for the textures
  82199. * @param images array of glTF image interfaces
  82200. * @param textures array of glTF texture interfaces
  82201. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82202. * @param imageData map of image file name to data
  82203. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82204. * @returns glTF PBR Metallic Roughness factors
  82205. */
  82206. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82207. /**
  82208. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82209. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82210. * @param mimeType mime type to use for the textures
  82211. * @param images array of glTF image interfaces
  82212. * @param textures array of glTF texture interfaces
  82213. * @param materials array of glTF material interfaces
  82214. * @param imageData map of image file name to data
  82215. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82216. */
  82217. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82218. private setMetallicRoughnessPbrMaterial;
  82219. private getPixelsFromTexture;
  82220. /**
  82221. * Extracts a texture from a Babylon texture into file data and glTF data
  82222. * @param babylonTexture Babylon texture to extract
  82223. * @param mimeType Mime Type of the babylonTexture
  82224. * @return glTF texture info, or null if the texture format is not supported
  82225. */
  82226. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82227. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82228. /**
  82229. * Builds a texture from base64 string
  82230. * @param base64Texture base64 texture string
  82231. * @param baseTextureName Name to use for the texture
  82232. * @param mimeType image mime type for the texture
  82233. * @param images array of images
  82234. * @param textures array of textures
  82235. * @param imageData map of image data
  82236. * @returns glTF texture info, or null if the texture format is not supported
  82237. */
  82238. private _getTextureInfoFromBase64;
  82239. }
  82240. }
  82241. declare module BABYLON {
  82242. /**
  82243. * Class for holding and downloading glTF file data
  82244. */
  82245. export class GLTFData {
  82246. /**
  82247. * Object which contains the file name as the key and its data as the value
  82248. */
  82249. glTFFiles: {
  82250. [fileName: string]: string | Blob;
  82251. };
  82252. /**
  82253. * Initializes the glTF file object
  82254. */
  82255. constructor();
  82256. /**
  82257. * Downloads the glTF data as files based on their names and data
  82258. */
  82259. downloadFiles(): void;
  82260. }
  82261. }
  82262. declare module BABYLON {
  82263. /**
  82264. * Holds a collection of exporter options and parameters
  82265. */
  82266. export interface IExportOptions {
  82267. /**
  82268. * Function which indicates whether a babylon node should be exported or not
  82269. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82270. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82271. */
  82272. shouldExportNode?(node: Node): boolean;
  82273. /**
  82274. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82275. * @param metadata source metadata to read from
  82276. * @returns the data to store to glTF node extras
  82277. */
  82278. metadataSelector?(metadata: any): any;
  82279. /**
  82280. * The sample rate to bake animation curves
  82281. */
  82282. animationSampleRate?: number;
  82283. /**
  82284. * Begin serialization without waiting for the scene to be ready
  82285. */
  82286. exportWithoutWaitingForScene?: boolean;
  82287. /**
  82288. * Indicates if coordinate system swapping root nodes should be included in export
  82289. */
  82290. includeCoordinateSystemConversionNodes?: boolean;
  82291. }
  82292. /**
  82293. * Class for generating glTF data from a Babylon scene.
  82294. */
  82295. export class GLTF2Export {
  82296. /**
  82297. * Exports the geometry of the scene to .gltf file format asynchronously
  82298. * @param scene Babylon scene with scene hierarchy information
  82299. * @param filePrefix File prefix to use when generating the glTF file
  82300. * @param options Exporter options
  82301. * @returns Returns an object with a .gltf file and associates texture names
  82302. * as keys and their data and paths as values
  82303. */
  82304. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82305. private static _PreExportAsync;
  82306. private static _PostExportAsync;
  82307. /**
  82308. * Exports the geometry of the scene to .glb file format asychronously
  82309. * @param scene Babylon scene with scene hierarchy information
  82310. * @param filePrefix File prefix to use when generating glb file
  82311. * @param options Exporter options
  82312. * @returns Returns an object with a .glb filename as key and data as value
  82313. */
  82314. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82315. }
  82316. }
  82317. declare module BABYLON.GLTF2.Exporter {
  82318. /**
  82319. * @hidden
  82320. */
  82321. export class _GLTFUtilities {
  82322. /**
  82323. * Creates a buffer view based on the supplied arguments
  82324. * @param bufferIndex index value of the specified buffer
  82325. * @param byteOffset byte offset value
  82326. * @param byteLength byte length of the bufferView
  82327. * @param byteStride byte distance between conequential elements
  82328. * @param name name of the buffer view
  82329. * @returns bufferView for glTF
  82330. */
  82331. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82332. /**
  82333. * Creates an accessor based on the supplied arguments
  82334. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82335. * @param name The name of the accessor
  82336. * @param type The type of the accessor
  82337. * @param componentType The datatype of components in the attribute
  82338. * @param count The number of attributes referenced by this accessor
  82339. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82340. * @param min Minimum value of each component in this attribute
  82341. * @param max Maximum value of each component in this attribute
  82342. * @returns accessor for glTF
  82343. */
  82344. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82345. /**
  82346. * Calculates the minimum and maximum values of an array of position floats
  82347. * @param positions Positions array of a mesh
  82348. * @param vertexStart Starting vertex offset to calculate min and max values
  82349. * @param vertexCount Number of vertices to check for min and max values
  82350. * @returns min number array and max number array
  82351. */
  82352. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82353. min: number[];
  82354. max: number[];
  82355. };
  82356. /**
  82357. * Converts a new right-handed Vector3
  82358. * @param vector vector3 array
  82359. * @returns right-handed Vector3
  82360. */
  82361. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82362. /**
  82363. * Converts a Vector3 to right-handed
  82364. * @param vector Vector3 to convert to right-handed
  82365. */
  82366. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82367. /**
  82368. * Converts a three element number array to right-handed
  82369. * @param vector number array to convert to right-handed
  82370. */
  82371. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82372. /**
  82373. * Converts a new right-handed Vector3
  82374. * @param vector vector3 array
  82375. * @returns right-handed Vector3
  82376. */
  82377. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82378. /**
  82379. * Converts a Vector3 to right-handed
  82380. * @param vector Vector3 to convert to right-handed
  82381. */
  82382. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82383. /**
  82384. * Converts a three element number array to right-handed
  82385. * @param vector number array to convert to right-handed
  82386. */
  82387. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82388. /**
  82389. * Converts a Vector4 to right-handed
  82390. * @param vector Vector4 to convert to right-handed
  82391. */
  82392. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82393. /**
  82394. * Converts a Vector4 to right-handed
  82395. * @param vector Vector4 to convert to right-handed
  82396. */
  82397. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82398. /**
  82399. * Converts a Quaternion to right-handed
  82400. * @param quaternion Source quaternion to convert to right-handed
  82401. */
  82402. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82403. /**
  82404. * Converts a Quaternion to right-handed
  82405. * @param quaternion Source quaternion to convert to right-handed
  82406. */
  82407. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82408. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82409. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82410. }
  82411. }
  82412. declare module BABYLON.GLTF2.Exporter {
  82413. /**
  82414. * Converts Babylon Scene into glTF 2.0.
  82415. * @hidden
  82416. */
  82417. export class _Exporter {
  82418. /**
  82419. * Stores the glTF to export
  82420. */
  82421. _glTF: IGLTF;
  82422. /**
  82423. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82424. */
  82425. _bufferViews: IBufferView[];
  82426. /**
  82427. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82428. */
  82429. _accessors: IAccessor[];
  82430. /**
  82431. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82432. */
  82433. _nodes: INode[];
  82434. /**
  82435. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82436. */
  82437. private _scenes;
  82438. /**
  82439. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82440. */
  82441. private _meshes;
  82442. /**
  82443. * Stores all the generated material information, which represents the appearance of each primitive
  82444. */
  82445. _materials: IMaterial[];
  82446. _materialMap: {
  82447. [materialID: number]: number;
  82448. };
  82449. /**
  82450. * Stores all the generated texture information, which is referenced by glTF materials
  82451. */
  82452. _textures: ITexture[];
  82453. /**
  82454. * Stores all the generated image information, which is referenced by glTF textures
  82455. */
  82456. _images: IImage[];
  82457. /**
  82458. * Stores all the texture samplers
  82459. */
  82460. _samplers: ISampler[];
  82461. /**
  82462. * Stores all the generated glTF skins
  82463. */
  82464. _skins: ISkin[];
  82465. /**
  82466. * Stores all the generated animation samplers, which is referenced by glTF animations
  82467. */
  82468. /**
  82469. * Stores the animations for glTF models
  82470. */
  82471. private _animations;
  82472. /**
  82473. * Stores the total amount of bytes stored in the glTF buffer
  82474. */
  82475. private _totalByteLength;
  82476. /**
  82477. * Stores a reference to the Babylon scene containing the source geometry and material information
  82478. */
  82479. _babylonScene: Scene;
  82480. /**
  82481. * Stores a map of the image data, where the key is the file name and the value
  82482. * is the image data
  82483. */
  82484. _imageData: {
  82485. [fileName: string]: {
  82486. data: Uint8Array;
  82487. mimeType: ImageMimeType;
  82488. };
  82489. };
  82490. /**
  82491. * Stores a map of the unique id of a node to its index in the node array
  82492. */
  82493. _nodeMap: {
  82494. [key: number]: number;
  82495. };
  82496. /**
  82497. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82498. */
  82499. _convertToRightHandedSystem: boolean;
  82500. /**
  82501. * Specifies if a Babylon node should be converted to right-handed on export
  82502. */
  82503. _convertToRightHandedSystemMap: {
  82504. [nodeId: number]: boolean;
  82505. };
  82506. _includeCoordinateSystemConversionNodes: boolean;
  82507. /**
  82508. * Baked animation sample rate
  82509. */
  82510. private _animationSampleRate;
  82511. private _options;
  82512. private _localEngine;
  82513. _glTFMaterialExporter: _GLTFMaterialExporter;
  82514. private _extensions;
  82515. private static _ExtensionNames;
  82516. private static _ExtensionFactories;
  82517. private _applyExtension;
  82518. private _applyExtensions;
  82519. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82520. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82521. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82522. [key: number]: number;
  82523. }): Promise<Nullable<INode>>;
  82524. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82525. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82526. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82527. private _forEachExtensions;
  82528. private _extensionsOnExporting;
  82529. /**
  82530. * Load glTF serializer extensions
  82531. */
  82532. private _loadExtensions;
  82533. /**
  82534. * Creates a glTF Exporter instance, which can accept optional exporter options
  82535. * @param babylonScene Babylon scene object
  82536. * @param options Options to modify the behavior of the exporter
  82537. */
  82538. constructor(babylonScene: Scene, options?: IExportOptions);
  82539. dispose(): void;
  82540. /**
  82541. * Registers a glTF exporter extension
  82542. * @param name Name of the extension to export
  82543. * @param factory The factory function that creates the exporter extension
  82544. */
  82545. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82546. /**
  82547. * Un-registers an exporter extension
  82548. * @param name The name fo the exporter extension
  82549. * @returns A boolean indicating whether the extension has been un-registered
  82550. */
  82551. static UnregisterExtension(name: string): boolean;
  82552. /**
  82553. * Lazy load a local engine
  82554. */
  82555. _getLocalEngine(): Engine;
  82556. private reorderIndicesBasedOnPrimitiveMode;
  82557. /**
  82558. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82559. * clock-wise during export to glTF
  82560. * @param submesh BabylonJS submesh
  82561. * @param primitiveMode Primitive mode of the mesh
  82562. * @param sideOrientation the winding order of the submesh
  82563. * @param vertexBufferKind The type of vertex attribute
  82564. * @param meshAttributeArray The vertex attribute data
  82565. * @param byteOffset The offset to the binary data
  82566. * @param binaryWriter The binary data for the glTF file
  82567. * @param convertToRightHandedSystem Converts the values to right-handed
  82568. */
  82569. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82570. /**
  82571. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82572. * clock-wise during export to glTF
  82573. * @param submesh BabylonJS submesh
  82574. * @param primitiveMode Primitive mode of the mesh
  82575. * @param sideOrientation the winding order of the submesh
  82576. * @param vertexBufferKind The type of vertex attribute
  82577. * @param meshAttributeArray The vertex attribute data
  82578. * @param byteOffset The offset to the binary data
  82579. * @param binaryWriter The binary data for the glTF file
  82580. * @param convertToRightHandedSystem Converts the values to right-handed
  82581. */
  82582. private reorderTriangleFillMode;
  82583. /**
  82584. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82585. * clock-wise during export to glTF
  82586. * @param submesh BabylonJS submesh
  82587. * @param primitiveMode Primitive mode of the mesh
  82588. * @param sideOrientation the winding order of the submesh
  82589. * @param vertexBufferKind The type of vertex attribute
  82590. * @param meshAttributeArray The vertex attribute data
  82591. * @param byteOffset The offset to the binary data
  82592. * @param binaryWriter The binary data for the glTF file
  82593. * @param convertToRightHandedSystem Converts the values to right-handed
  82594. */
  82595. private reorderTriangleStripDrawMode;
  82596. /**
  82597. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82598. * clock-wise during export to glTF
  82599. * @param submesh BabylonJS submesh
  82600. * @param primitiveMode Primitive mode of the mesh
  82601. * @param sideOrientation the winding order of the submesh
  82602. * @param vertexBufferKind The type of vertex attribute
  82603. * @param meshAttributeArray The vertex attribute data
  82604. * @param byteOffset The offset to the binary data
  82605. * @param binaryWriter The binary data for the glTF file
  82606. * @param convertToRightHandedSystem Converts the values to right-handed
  82607. */
  82608. private reorderTriangleFanMode;
  82609. /**
  82610. * Writes the vertex attribute data to binary
  82611. * @param vertices The vertices to write to the binary writer
  82612. * @param byteOffset The offset into the binary writer to overwrite binary data
  82613. * @param vertexAttributeKind The vertex attribute type
  82614. * @param meshAttributeArray The vertex attribute data
  82615. * @param binaryWriter The writer containing the binary data
  82616. * @param convertToRightHandedSystem Converts the values to right-handed
  82617. */
  82618. private writeVertexAttributeData;
  82619. /**
  82620. * Writes mesh attribute data to a data buffer
  82621. * Returns the bytelength of the data
  82622. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82623. * @param meshAttributeArray Array containing the attribute data
  82624. * @param byteStride Specifies the space between data
  82625. * @param binaryWriter The buffer to write the binary data to
  82626. * @param convertToRightHandedSystem Converts the values to right-handed
  82627. */
  82628. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82629. /**
  82630. * Generates glTF json data
  82631. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82632. * @param glTFPrefix Text to use when prefixing a glTF file
  82633. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82634. * @returns json data as string
  82635. */
  82636. private generateJSON;
  82637. /**
  82638. * Generates data for .gltf and .bin files based on the glTF prefix string
  82639. * @param glTFPrefix Text to use when prefixing a glTF file
  82640. * @param dispose Dispose the exporter
  82641. * @returns GLTFData with glTF file data
  82642. */
  82643. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82644. /**
  82645. * Creates a binary buffer for glTF
  82646. * @returns array buffer for binary data
  82647. */
  82648. private _generateBinaryAsync;
  82649. /**
  82650. * Pads the number to a multiple of 4
  82651. * @param num number to pad
  82652. * @returns padded number
  82653. */
  82654. private _getPadding;
  82655. /**
  82656. * @hidden
  82657. */
  82658. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82659. /**
  82660. * Sets the TRS for each node
  82661. * @param node glTF Node for storing the transformation data
  82662. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82663. * @param convertToRightHandedSystem Converts the values to right-handed
  82664. */
  82665. private setNodeTransformation;
  82666. private getVertexBufferFromMesh;
  82667. /**
  82668. * Creates a bufferview based on the vertices type for the Babylon mesh
  82669. * @param kind Indicates the type of vertices data
  82670. * @param componentType Indicates the numerical type used to store the data
  82671. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82672. * @param binaryWriter The buffer to write the bufferview data to
  82673. * @param convertToRightHandedSystem Converts the values to right-handed
  82674. */
  82675. private createBufferViewKind;
  82676. /**
  82677. * The primitive mode of the Babylon mesh
  82678. * @param babylonMesh The BabylonJS mesh
  82679. */
  82680. private getMeshPrimitiveMode;
  82681. /**
  82682. * Sets the primitive mode of the glTF mesh primitive
  82683. * @param meshPrimitive glTF mesh primitive
  82684. * @param primitiveMode The primitive mode
  82685. */
  82686. private setPrimitiveMode;
  82687. /**
  82688. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82689. * @param meshPrimitive glTF mesh primitive
  82690. * @param attributeKind vertex attribute
  82691. * @returns boolean specifying if uv coordinates are present
  82692. */
  82693. private setAttributeKind;
  82694. /**
  82695. * Sets data for the primitive attributes of each submesh
  82696. * @param mesh glTF Mesh object to store the primitive attribute information
  82697. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82698. * @param binaryWriter Buffer to write the attribute data to
  82699. * @param convertToRightHandedSystem Converts the values to right-handed
  82700. */
  82701. private setPrimitiveAttributesAsync;
  82702. /**
  82703. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82704. * @param node The node to check
  82705. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82706. */
  82707. private isBabylonCoordinateSystemConvertingNode;
  82708. /**
  82709. * Creates a glTF scene based on the array of meshes
  82710. * Returns the the total byte offset
  82711. * @param babylonScene Babylon scene to get the mesh data from
  82712. * @param binaryWriter Buffer to write binary data to
  82713. */
  82714. private createSceneAsync;
  82715. /**
  82716. * Creates a mapping of Node unique id to node index and handles animations
  82717. * @param babylonScene Babylon Scene
  82718. * @param nodes Babylon transform nodes
  82719. * @param binaryWriter Buffer to write binary data to
  82720. * @returns Node mapping of unique id to index
  82721. */
  82722. private createNodeMapAndAnimationsAsync;
  82723. /**
  82724. * Creates a glTF node from a Babylon mesh
  82725. * @param babylonMesh Source Babylon mesh
  82726. * @param binaryWriter Buffer for storing geometry data
  82727. * @param convertToRightHandedSystem Converts the values to right-handed
  82728. * @param nodeMap Node mapping of unique id to glTF node index
  82729. * @returns glTF node
  82730. */
  82731. private createNodeAsync;
  82732. /**
  82733. * Creates a glTF skin from a Babylon skeleton
  82734. * @param babylonScene Babylon Scene
  82735. * @param nodes Babylon transform nodes
  82736. * @param binaryWriter Buffer to write binary data to
  82737. * @returns Node mapping of unique id to index
  82738. */
  82739. private createSkinsAsync;
  82740. }
  82741. /**
  82742. * @hidden
  82743. *
  82744. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82745. */
  82746. export class _BinaryWriter {
  82747. /**
  82748. * Array buffer which stores all binary data
  82749. */
  82750. private _arrayBuffer;
  82751. /**
  82752. * View of the array buffer
  82753. */
  82754. private _dataView;
  82755. /**
  82756. * byte offset of data in array buffer
  82757. */
  82758. private _byteOffset;
  82759. /**
  82760. * Initialize binary writer with an initial byte length
  82761. * @param byteLength Initial byte length of the array buffer
  82762. */
  82763. constructor(byteLength: number);
  82764. /**
  82765. * Resize the array buffer to the specified byte length
  82766. * @param byteLength
  82767. */
  82768. private resizeBuffer;
  82769. /**
  82770. * Get an array buffer with the length of the byte offset
  82771. * @returns ArrayBuffer resized to the byte offset
  82772. */
  82773. getArrayBuffer(): ArrayBuffer;
  82774. /**
  82775. * Get the byte offset of the array buffer
  82776. * @returns byte offset
  82777. */
  82778. getByteOffset(): number;
  82779. /**
  82780. * Stores an UInt8 in the array buffer
  82781. * @param entry
  82782. * @param byteOffset If defined, specifies where to set the value as an offset.
  82783. */
  82784. setUInt8(entry: number, byteOffset?: number): void;
  82785. /**
  82786. * Stores an UInt16 in the array buffer
  82787. * @param entry
  82788. * @param byteOffset If defined, specifies where to set the value as an offset.
  82789. */
  82790. setUInt16(entry: number, byteOffset?: number): void;
  82791. /**
  82792. * Gets an UInt32 in the array buffer
  82793. * @param entry
  82794. * @param byteOffset If defined, specifies where to set the value as an offset.
  82795. */
  82796. getUInt32(byteOffset: number): number;
  82797. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82798. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82799. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82800. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82801. /**
  82802. * Stores a Float32 in the array buffer
  82803. * @param entry
  82804. */
  82805. setFloat32(entry: number, byteOffset?: number): void;
  82806. /**
  82807. * Stores an UInt32 in the array buffer
  82808. * @param entry
  82809. * @param byteOffset If defined, specifies where to set the value as an offset.
  82810. */
  82811. setUInt32(entry: number, byteOffset?: number): void;
  82812. }
  82813. }
  82814. declare module BABYLON.GLTF2.Exporter {
  82815. /**
  82816. * @hidden
  82817. * Interface to store animation data.
  82818. */
  82819. export interface _IAnimationData {
  82820. /**
  82821. * Keyframe data.
  82822. */
  82823. inputs: number[];
  82824. /**
  82825. * Value data.
  82826. */
  82827. outputs: number[][];
  82828. /**
  82829. * Animation interpolation data.
  82830. */
  82831. samplerInterpolation: AnimationSamplerInterpolation;
  82832. /**
  82833. * Minimum keyframe value.
  82834. */
  82835. inputsMin: number;
  82836. /**
  82837. * Maximum keyframe value.
  82838. */
  82839. inputsMax: number;
  82840. }
  82841. /**
  82842. * @hidden
  82843. */
  82844. export interface _IAnimationInfo {
  82845. /**
  82846. * The target channel for the animation
  82847. */
  82848. animationChannelTargetPath: AnimationChannelTargetPath;
  82849. /**
  82850. * The glTF accessor type for the data.
  82851. */
  82852. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82853. /**
  82854. * Specifies if quaternions should be used.
  82855. */
  82856. useQuaternion: boolean;
  82857. }
  82858. /**
  82859. * @hidden
  82860. * Utility class for generating glTF animation data from BabylonJS.
  82861. */
  82862. export class _GLTFAnimation {
  82863. /**
  82864. * @ignore
  82865. *
  82866. * Creates glTF channel animation from BabylonJS animation.
  82867. * @param babylonTransformNode - BabylonJS mesh.
  82868. * @param animation - animation.
  82869. * @param animationChannelTargetPath - The target animation channel.
  82870. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82871. * @param useQuaternion - Specifies if quaternions are used.
  82872. * @returns nullable IAnimationData
  82873. */
  82874. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82875. private static _DeduceAnimationInfo;
  82876. /**
  82877. * @ignore
  82878. * Create node animations from the transform node animations
  82879. * @param babylonNode
  82880. * @param runtimeGLTFAnimation
  82881. * @param idleGLTFAnimations
  82882. * @param nodeMap
  82883. * @param nodes
  82884. * @param binaryWriter
  82885. * @param bufferViews
  82886. * @param accessors
  82887. * @param convertToRightHandedSystem
  82888. * @param animationSampleRate
  82889. */
  82890. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82891. [key: number]: number;
  82892. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82893. /**
  82894. * @ignore
  82895. * Create node animations from the animation groups
  82896. * @param babylonScene
  82897. * @param glTFAnimations
  82898. * @param nodeMap
  82899. * @param nodes
  82900. * @param binaryWriter
  82901. * @param bufferViews
  82902. * @param accessors
  82903. * @param convertToRightHandedSystemMap
  82904. * @param animationSampleRate
  82905. */
  82906. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82907. [key: number]: number;
  82908. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82909. [nodeId: number]: boolean;
  82910. }, animationSampleRate: number): void;
  82911. private static AddAnimation;
  82912. /**
  82913. * Create a baked animation
  82914. * @param babylonTransformNode BabylonJS mesh
  82915. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82916. * @param animationChannelTargetPath animation target channel
  82917. * @param minFrame minimum animation frame
  82918. * @param maxFrame maximum animation frame
  82919. * @param fps frames per second of the animation
  82920. * @param inputs input key frames of the animation
  82921. * @param outputs output key frame data of the animation
  82922. * @param convertToRightHandedSystem converts the values to right-handed
  82923. * @param useQuaternion specifies if quaternions should be used
  82924. */
  82925. private static _CreateBakedAnimation;
  82926. private static _ConvertFactorToVector3OrQuaternion;
  82927. private static _SetInterpolatedValue;
  82928. /**
  82929. * Creates linear animation from the animation key frames
  82930. * @param babylonTransformNode BabylonJS mesh
  82931. * @param animation BabylonJS animation
  82932. * @param animationChannelTargetPath The target animation channel
  82933. * @param frameDelta The difference between the last and first frame of the animation
  82934. * @param inputs Array to store the key frame times
  82935. * @param outputs Array to store the key frame data
  82936. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82937. * @param useQuaternion Specifies if quaternions are used in the animation
  82938. */
  82939. private static _CreateLinearOrStepAnimation;
  82940. /**
  82941. * Creates cubic spline animation from the animation key frames
  82942. * @param babylonTransformNode BabylonJS mesh
  82943. * @param animation BabylonJS animation
  82944. * @param animationChannelTargetPath The target animation channel
  82945. * @param frameDelta The difference between the last and first frame of the animation
  82946. * @param inputs Array to store the key frame times
  82947. * @param outputs Array to store the key frame data
  82948. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82949. * @param useQuaternion Specifies if quaternions are used in the animation
  82950. */
  82951. private static _CreateCubicSplineAnimation;
  82952. private static _GetBasePositionRotationOrScale;
  82953. /**
  82954. * Adds a key frame value
  82955. * @param keyFrame
  82956. * @param animation
  82957. * @param outputs
  82958. * @param animationChannelTargetPath
  82959. * @param basePositionRotationOrScale
  82960. * @param convertToRightHandedSystem
  82961. * @param useQuaternion
  82962. */
  82963. private static _AddKeyframeValue;
  82964. /**
  82965. * Determine the interpolation based on the key frames
  82966. * @param keyFrames
  82967. * @param animationChannelTargetPath
  82968. * @param useQuaternion
  82969. */
  82970. private static _DeduceInterpolation;
  82971. /**
  82972. * Adds an input tangent or output tangent to the output data
  82973. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82974. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82975. * @param outputs The animation data by keyframe
  82976. * @param animationChannelTargetPath The target animation channel
  82977. * @param interpolation The interpolation type
  82978. * @param keyFrame The key frame with the animation data
  82979. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82980. * @param useQuaternion Specifies if quaternions are used
  82981. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82982. */
  82983. private static AddSplineTangent;
  82984. /**
  82985. * Get the minimum and maximum key frames' frame values
  82986. * @param keyFrames animation key frames
  82987. * @returns the minimum and maximum key frame value
  82988. */
  82989. private static calculateMinMaxKeyFrames;
  82990. }
  82991. }
  82992. declare module BABYLON.GLTF2.Exporter {
  82993. /** @hidden */
  82994. export var textureTransformPixelShader: {
  82995. name: string;
  82996. shader: string;
  82997. };
  82998. }
  82999. declare module BABYLON.GLTF2.Exporter.Extensions {
  83000. /**
  83001. * @hidden
  83002. */
  83003. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83004. private _recordedTextures;
  83005. /** Name of this extension */
  83006. readonly name: string;
  83007. /** Defines whether this extension is enabled */
  83008. enabled: boolean;
  83009. /** Defines whether this extension is required */
  83010. required: boolean;
  83011. /** Reference to the glTF exporter */
  83012. private _wasUsed;
  83013. constructor(exporter: _Exporter);
  83014. dispose(): void;
  83015. /** @hidden */
  83016. get wasUsed(): boolean;
  83017. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83018. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83019. /**
  83020. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83021. * @param babylonTexture
  83022. * @param offset
  83023. * @param rotation
  83024. * @param scale
  83025. * @param scene
  83026. */
  83027. private _textureTransformTextureAsync;
  83028. }
  83029. }
  83030. declare module BABYLON.GLTF2.Exporter.Extensions {
  83031. /**
  83032. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83033. */
  83034. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83035. /** The name of this extension. */
  83036. readonly name: string;
  83037. /** Defines whether this extension is enabled. */
  83038. enabled: boolean;
  83039. /** Defines whether this extension is required */
  83040. required: boolean;
  83041. /** Reference to the glTF exporter */
  83042. private _exporter;
  83043. private _lights;
  83044. /** @hidden */
  83045. constructor(exporter: _Exporter);
  83046. /** @hidden */
  83047. dispose(): void;
  83048. /** @hidden */
  83049. get wasUsed(): boolean;
  83050. /** @hidden */
  83051. onExporting(): void;
  83052. /**
  83053. * Define this method to modify the default behavior when exporting a node
  83054. * @param context The context when exporting the node
  83055. * @param node glTF node
  83056. * @param babylonNode BabylonJS node
  83057. * @param nodeMap Node mapping of unique id to glTF node index
  83058. * @returns nullable INode promise
  83059. */
  83060. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83061. [key: number]: number;
  83062. }): Promise<Nullable<INode>>;
  83063. }
  83064. }
  83065. declare module BABYLON.GLTF2.Exporter.Extensions {
  83066. /**
  83067. * @hidden
  83068. */
  83069. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83070. /** Name of this extension */
  83071. readonly name: string;
  83072. /** Defines whether this extension is enabled */
  83073. enabled: boolean;
  83074. /** Defines whether this extension is required */
  83075. required: boolean;
  83076. /** Reference to the glTF exporter */
  83077. private _textureInfos;
  83078. private _exportedTextures;
  83079. private _wasUsed;
  83080. constructor(exporter: _Exporter);
  83081. dispose(): void;
  83082. /** @hidden */
  83083. get wasUsed(): boolean;
  83084. private _getTextureIndex;
  83085. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83086. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83087. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83088. }
  83089. }
  83090. declare module BABYLON.GLTF2.Exporter.Extensions {
  83091. /**
  83092. * @hidden
  83093. */
  83094. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83095. /** Name of this extension */
  83096. readonly name: string;
  83097. /** Defines whether this extension is enabled */
  83098. enabled: boolean;
  83099. /** Defines whether this extension is required */
  83100. required: boolean;
  83101. private _wasUsed;
  83102. constructor(exporter: _Exporter);
  83103. /** @hidden */
  83104. get wasUsed(): boolean;
  83105. dispose(): void;
  83106. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83107. }
  83108. }
  83109. declare module BABYLON {
  83110. /**
  83111. * Class for generating STL data from a Babylon scene.
  83112. */
  83113. export class STLExport {
  83114. /**
  83115. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83116. * @param meshes list defines the mesh to serialize
  83117. * @param download triggers the automatic download of the file.
  83118. * @param fileName changes the downloads fileName.
  83119. * @param binary changes the STL to a binary type.
  83120. * @param isLittleEndian toggle for binary type exporter.
  83121. * @returns the STL as UTF8 string
  83122. */
  83123. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83124. }
  83125. }
  83126. declare module "babylonjs-gltf2interface" {
  83127. export = BABYLON.GLTF2;
  83128. }
  83129. /**
  83130. * Module for glTF 2.0 Interface
  83131. */
  83132. declare module BABYLON.GLTF2 {
  83133. /**
  83134. * The datatype of the components in the attribute
  83135. */
  83136. const enum AccessorComponentType {
  83137. /**
  83138. * Byte
  83139. */
  83140. BYTE = 5120,
  83141. /**
  83142. * Unsigned Byte
  83143. */
  83144. UNSIGNED_BYTE = 5121,
  83145. /**
  83146. * Short
  83147. */
  83148. SHORT = 5122,
  83149. /**
  83150. * Unsigned Short
  83151. */
  83152. UNSIGNED_SHORT = 5123,
  83153. /**
  83154. * Unsigned Int
  83155. */
  83156. UNSIGNED_INT = 5125,
  83157. /**
  83158. * Float
  83159. */
  83160. FLOAT = 5126,
  83161. }
  83162. /**
  83163. * Specifies if the attirbute is a scalar, vector, or matrix
  83164. */
  83165. const enum AccessorType {
  83166. /**
  83167. * Scalar
  83168. */
  83169. SCALAR = "SCALAR",
  83170. /**
  83171. * Vector2
  83172. */
  83173. VEC2 = "VEC2",
  83174. /**
  83175. * Vector3
  83176. */
  83177. VEC3 = "VEC3",
  83178. /**
  83179. * Vector4
  83180. */
  83181. VEC4 = "VEC4",
  83182. /**
  83183. * Matrix2x2
  83184. */
  83185. MAT2 = "MAT2",
  83186. /**
  83187. * Matrix3x3
  83188. */
  83189. MAT3 = "MAT3",
  83190. /**
  83191. * Matrix4x4
  83192. */
  83193. MAT4 = "MAT4",
  83194. }
  83195. /**
  83196. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83197. */
  83198. const enum AnimationChannelTargetPath {
  83199. /**
  83200. * Translation
  83201. */
  83202. TRANSLATION = "translation",
  83203. /**
  83204. * Rotation
  83205. */
  83206. ROTATION = "rotation",
  83207. /**
  83208. * Scale
  83209. */
  83210. SCALE = "scale",
  83211. /**
  83212. * Weights
  83213. */
  83214. WEIGHTS = "weights",
  83215. }
  83216. /**
  83217. * Interpolation algorithm
  83218. */
  83219. const enum AnimationSamplerInterpolation {
  83220. /**
  83221. * The animated values are linearly interpolated between keyframes
  83222. */
  83223. LINEAR = "LINEAR",
  83224. /**
  83225. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83226. */
  83227. STEP = "STEP",
  83228. /**
  83229. * The animation's interpolation is computed using a cubic spline with specified tangents
  83230. */
  83231. CUBICSPLINE = "CUBICSPLINE",
  83232. }
  83233. /**
  83234. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83235. */
  83236. const enum CameraType {
  83237. /**
  83238. * A perspective camera containing properties to create a perspective projection matrix
  83239. */
  83240. PERSPECTIVE = "perspective",
  83241. /**
  83242. * An orthographic camera containing properties to create an orthographic projection matrix
  83243. */
  83244. ORTHOGRAPHIC = "orthographic",
  83245. }
  83246. /**
  83247. * The mime-type of the image
  83248. */
  83249. const enum ImageMimeType {
  83250. /**
  83251. * JPEG Mime-type
  83252. */
  83253. JPEG = "image/jpeg",
  83254. /**
  83255. * PNG Mime-type
  83256. */
  83257. PNG = "image/png",
  83258. }
  83259. /**
  83260. * The alpha rendering mode of the material
  83261. */
  83262. const enum MaterialAlphaMode {
  83263. /**
  83264. * The alpha value is ignored and the rendered output is fully opaque
  83265. */
  83266. OPAQUE = "OPAQUE",
  83267. /**
  83268. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83269. */
  83270. MASK = "MASK",
  83271. /**
  83272. * 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)
  83273. */
  83274. BLEND = "BLEND",
  83275. }
  83276. /**
  83277. * The type of the primitives to render
  83278. */
  83279. const enum MeshPrimitiveMode {
  83280. /**
  83281. * Points
  83282. */
  83283. POINTS = 0,
  83284. /**
  83285. * Lines
  83286. */
  83287. LINES = 1,
  83288. /**
  83289. * Line Loop
  83290. */
  83291. LINE_LOOP = 2,
  83292. /**
  83293. * Line Strip
  83294. */
  83295. LINE_STRIP = 3,
  83296. /**
  83297. * Triangles
  83298. */
  83299. TRIANGLES = 4,
  83300. /**
  83301. * Triangle Strip
  83302. */
  83303. TRIANGLE_STRIP = 5,
  83304. /**
  83305. * Triangle Fan
  83306. */
  83307. TRIANGLE_FAN = 6,
  83308. }
  83309. /**
  83310. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83311. */
  83312. const enum TextureMagFilter {
  83313. /**
  83314. * Nearest
  83315. */
  83316. NEAREST = 9728,
  83317. /**
  83318. * Linear
  83319. */
  83320. LINEAR = 9729,
  83321. }
  83322. /**
  83323. * Minification filter. All valid values correspond to WebGL enums
  83324. */
  83325. const enum TextureMinFilter {
  83326. /**
  83327. * Nearest
  83328. */
  83329. NEAREST = 9728,
  83330. /**
  83331. * Linear
  83332. */
  83333. LINEAR = 9729,
  83334. /**
  83335. * Nearest Mip-Map Nearest
  83336. */
  83337. NEAREST_MIPMAP_NEAREST = 9984,
  83338. /**
  83339. * Linear Mipmap Nearest
  83340. */
  83341. LINEAR_MIPMAP_NEAREST = 9985,
  83342. /**
  83343. * Nearest Mipmap Linear
  83344. */
  83345. NEAREST_MIPMAP_LINEAR = 9986,
  83346. /**
  83347. * Linear Mipmap Linear
  83348. */
  83349. LINEAR_MIPMAP_LINEAR = 9987,
  83350. }
  83351. /**
  83352. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83353. */
  83354. const enum TextureWrapMode {
  83355. /**
  83356. * Clamp to Edge
  83357. */
  83358. CLAMP_TO_EDGE = 33071,
  83359. /**
  83360. * Mirrored Repeat
  83361. */
  83362. MIRRORED_REPEAT = 33648,
  83363. /**
  83364. * Repeat
  83365. */
  83366. REPEAT = 10497,
  83367. }
  83368. /**
  83369. * glTF Property
  83370. */
  83371. interface IProperty {
  83372. /**
  83373. * Dictionary object with extension-specific objects
  83374. */
  83375. extensions?: {
  83376. [key: string]: any;
  83377. };
  83378. /**
  83379. * Application-Specific data
  83380. */
  83381. extras?: any;
  83382. }
  83383. /**
  83384. * glTF Child of Root Property
  83385. */
  83386. interface IChildRootProperty extends IProperty {
  83387. /**
  83388. * The user-defined name of this object
  83389. */
  83390. name?: string;
  83391. }
  83392. /**
  83393. * Indices of those attributes that deviate from their initialization value
  83394. */
  83395. interface IAccessorSparseIndices extends IProperty {
  83396. /**
  83397. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83398. */
  83399. bufferView: number;
  83400. /**
  83401. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83402. */
  83403. byteOffset?: number;
  83404. /**
  83405. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83406. */
  83407. componentType: AccessorComponentType;
  83408. }
  83409. /**
  83410. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83411. */
  83412. interface IAccessorSparseValues extends IProperty {
  83413. /**
  83414. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83415. */
  83416. bufferView: number;
  83417. /**
  83418. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83419. */
  83420. byteOffset?: number;
  83421. }
  83422. /**
  83423. * Sparse storage of attributes that deviate from their initialization value
  83424. */
  83425. interface IAccessorSparse extends IProperty {
  83426. /**
  83427. * The number of attributes encoded in this sparse accessor
  83428. */
  83429. count: number;
  83430. /**
  83431. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83432. */
  83433. indices: IAccessorSparseIndices;
  83434. /**
  83435. * 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
  83436. */
  83437. values: IAccessorSparseValues;
  83438. }
  83439. /**
  83440. * 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
  83441. */
  83442. interface IAccessor extends IChildRootProperty {
  83443. /**
  83444. * The index of the bufferview
  83445. */
  83446. bufferView?: number;
  83447. /**
  83448. * The offset relative to the start of the bufferView in bytes
  83449. */
  83450. byteOffset?: number;
  83451. /**
  83452. * The datatype of components in the attribute
  83453. */
  83454. componentType: AccessorComponentType;
  83455. /**
  83456. * Specifies whether integer data values should be normalized
  83457. */
  83458. normalized?: boolean;
  83459. /**
  83460. * The number of attributes referenced by this accessor
  83461. */
  83462. count: number;
  83463. /**
  83464. * Specifies if the attribute is a scalar, vector, or matrix
  83465. */
  83466. type: AccessorType;
  83467. /**
  83468. * Maximum value of each component in this attribute
  83469. */
  83470. max?: number[];
  83471. /**
  83472. * Minimum value of each component in this attribute
  83473. */
  83474. min?: number[];
  83475. /**
  83476. * Sparse storage of attributes that deviate from their initialization value
  83477. */
  83478. sparse?: IAccessorSparse;
  83479. }
  83480. /**
  83481. * Targets an animation's sampler at a node's property
  83482. */
  83483. interface IAnimationChannel extends IProperty {
  83484. /**
  83485. * The index of a sampler in this animation used to compute the value for the target
  83486. */
  83487. sampler: number;
  83488. /**
  83489. * The index of the node and TRS property to target
  83490. */
  83491. target: IAnimationChannelTarget;
  83492. }
  83493. /**
  83494. * The index of the node and TRS property that an animation channel targets
  83495. */
  83496. interface IAnimationChannelTarget extends IProperty {
  83497. /**
  83498. * The index of the node to target
  83499. */
  83500. node: number;
  83501. /**
  83502. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83503. */
  83504. path: AnimationChannelTargetPath;
  83505. }
  83506. /**
  83507. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83508. */
  83509. interface IAnimationSampler extends IProperty {
  83510. /**
  83511. * The index of an accessor containing keyframe input values, e.g., time
  83512. */
  83513. input: number;
  83514. /**
  83515. * Interpolation algorithm
  83516. */
  83517. interpolation?: AnimationSamplerInterpolation;
  83518. /**
  83519. * The index of an accessor, containing keyframe output values
  83520. */
  83521. output: number;
  83522. }
  83523. /**
  83524. * A keyframe animation
  83525. */
  83526. interface IAnimation extends IChildRootProperty {
  83527. /**
  83528. * An array of channels, each of which targets an animation's sampler at a node's property
  83529. */
  83530. channels: IAnimationChannel[];
  83531. /**
  83532. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83533. */
  83534. samplers: IAnimationSampler[];
  83535. }
  83536. /**
  83537. * Metadata about the glTF asset
  83538. */
  83539. interface IAsset extends IChildRootProperty {
  83540. /**
  83541. * A copyright message suitable for display to credit the content creator
  83542. */
  83543. copyright?: string;
  83544. /**
  83545. * Tool that generated this glTF model. Useful for debugging
  83546. */
  83547. generator?: string;
  83548. /**
  83549. * The glTF version that this asset targets
  83550. */
  83551. version: string;
  83552. /**
  83553. * The minimum glTF version that this asset targets
  83554. */
  83555. minVersion?: string;
  83556. }
  83557. /**
  83558. * A buffer points to binary geometry, animation, or skins
  83559. */
  83560. interface IBuffer extends IChildRootProperty {
  83561. /**
  83562. * 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
  83563. */
  83564. uri?: string;
  83565. /**
  83566. * The length of the buffer in bytes
  83567. */
  83568. byteLength: number;
  83569. }
  83570. /**
  83571. * A view into a buffer generally representing a subset of the buffer
  83572. */
  83573. interface IBufferView extends IChildRootProperty {
  83574. /**
  83575. * The index of the buffer
  83576. */
  83577. buffer: number;
  83578. /**
  83579. * The offset into the buffer in bytes
  83580. */
  83581. byteOffset?: number;
  83582. /**
  83583. * The lenth of the bufferView in bytes
  83584. */
  83585. byteLength: number;
  83586. /**
  83587. * The stride, in bytes
  83588. */
  83589. byteStride?: number;
  83590. }
  83591. /**
  83592. * An orthographic camera containing properties to create an orthographic projection matrix
  83593. */
  83594. interface ICameraOrthographic extends IProperty {
  83595. /**
  83596. * The floating-point horizontal magnification of the view. Must not be zero
  83597. */
  83598. xmag: number;
  83599. /**
  83600. * The floating-point vertical magnification of the view. Must not be zero
  83601. */
  83602. ymag: number;
  83603. /**
  83604. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83605. */
  83606. zfar: number;
  83607. /**
  83608. * The floating-point distance to the near clipping plane
  83609. */
  83610. znear: number;
  83611. }
  83612. /**
  83613. * A perspective camera containing properties to create a perspective projection matrix
  83614. */
  83615. interface ICameraPerspective extends IProperty {
  83616. /**
  83617. * The floating-point aspect ratio of the field of view
  83618. */
  83619. aspectRatio?: number;
  83620. /**
  83621. * The floating-point vertical field of view in radians
  83622. */
  83623. yfov: number;
  83624. /**
  83625. * The floating-point distance to the far clipping plane
  83626. */
  83627. zfar?: number;
  83628. /**
  83629. * The floating-point distance to the near clipping plane
  83630. */
  83631. znear: number;
  83632. }
  83633. /**
  83634. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83635. */
  83636. interface ICamera extends IChildRootProperty {
  83637. /**
  83638. * An orthographic camera containing properties to create an orthographic projection matrix
  83639. */
  83640. orthographic?: ICameraOrthographic;
  83641. /**
  83642. * A perspective camera containing properties to create a perspective projection matrix
  83643. */
  83644. perspective?: ICameraPerspective;
  83645. /**
  83646. * Specifies if the camera uses a perspective or orthographic projection
  83647. */
  83648. type: CameraType;
  83649. }
  83650. /**
  83651. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83652. */
  83653. interface IImage extends IChildRootProperty {
  83654. /**
  83655. * 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
  83656. */
  83657. uri?: string;
  83658. /**
  83659. * The image's MIME type
  83660. */
  83661. mimeType?: ImageMimeType;
  83662. /**
  83663. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83664. */
  83665. bufferView?: number;
  83666. }
  83667. /**
  83668. * Material Normal Texture Info
  83669. */
  83670. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83671. /**
  83672. * The scalar multiplier applied to each normal vector of the normal texture
  83673. */
  83674. scale?: number;
  83675. }
  83676. /**
  83677. * Material Occlusion Texture Info
  83678. */
  83679. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83680. /**
  83681. * A scalar multiplier controlling the amount of occlusion applied
  83682. */
  83683. strength?: number;
  83684. }
  83685. /**
  83686. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83687. */
  83688. interface IMaterialPbrMetallicRoughness {
  83689. /**
  83690. * The material's base color factor
  83691. */
  83692. baseColorFactor?: number[];
  83693. /**
  83694. * The base color texture
  83695. */
  83696. baseColorTexture?: ITextureInfo;
  83697. /**
  83698. * The metalness of the material
  83699. */
  83700. metallicFactor?: number;
  83701. /**
  83702. * The roughness of the material
  83703. */
  83704. roughnessFactor?: number;
  83705. /**
  83706. * The metallic-roughness texture
  83707. */
  83708. metallicRoughnessTexture?: ITextureInfo;
  83709. }
  83710. /**
  83711. * The material appearance of a primitive
  83712. */
  83713. interface IMaterial extends IChildRootProperty {
  83714. /**
  83715. * 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
  83716. */
  83717. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83718. /**
  83719. * The normal map texture
  83720. */
  83721. normalTexture?: IMaterialNormalTextureInfo;
  83722. /**
  83723. * The occlusion map texture
  83724. */
  83725. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83726. /**
  83727. * The emissive map texture
  83728. */
  83729. emissiveTexture?: ITextureInfo;
  83730. /**
  83731. * 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
  83732. */
  83733. emissiveFactor?: number[];
  83734. /**
  83735. * The alpha rendering mode of the material
  83736. */
  83737. alphaMode?: MaterialAlphaMode;
  83738. /**
  83739. * The alpha cutoff value of the material
  83740. */
  83741. alphaCutoff?: number;
  83742. /**
  83743. * Specifies whether the material is double sided
  83744. */
  83745. doubleSided?: boolean;
  83746. }
  83747. /**
  83748. * Geometry to be rendered with the given material
  83749. */
  83750. interface IMeshPrimitive extends IProperty {
  83751. /**
  83752. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83753. */
  83754. attributes: {
  83755. [name: string]: number;
  83756. };
  83757. /**
  83758. * The index of the accessor that contains the indices
  83759. */
  83760. indices?: number;
  83761. /**
  83762. * The index of the material to apply to this primitive when rendering
  83763. */
  83764. material?: number;
  83765. /**
  83766. * The type of primitives to render. All valid values correspond to WebGL enums
  83767. */
  83768. mode?: MeshPrimitiveMode;
  83769. /**
  83770. * 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
  83771. */
  83772. targets?: {
  83773. [name: string]: number;
  83774. }[];
  83775. }
  83776. /**
  83777. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83778. */
  83779. interface IMesh extends IChildRootProperty {
  83780. /**
  83781. * An array of primitives, each defining geometry to be rendered with a material
  83782. */
  83783. primitives: IMeshPrimitive[];
  83784. /**
  83785. * Array of weights to be applied to the Morph Targets
  83786. */
  83787. weights?: number[];
  83788. }
  83789. /**
  83790. * A node in the node hierarchy
  83791. */
  83792. interface INode extends IChildRootProperty {
  83793. /**
  83794. * The index of the camera referenced by this node
  83795. */
  83796. camera?: number;
  83797. /**
  83798. * The indices of this node's children
  83799. */
  83800. children?: number[];
  83801. /**
  83802. * The index of the skin referenced by this node
  83803. */
  83804. skin?: number;
  83805. /**
  83806. * A floating-point 4x4 transformation matrix stored in column-major order
  83807. */
  83808. matrix?: number[];
  83809. /**
  83810. * The index of the mesh in this node
  83811. */
  83812. mesh?: number;
  83813. /**
  83814. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83815. */
  83816. rotation?: number[];
  83817. /**
  83818. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83819. */
  83820. scale?: number[];
  83821. /**
  83822. * The node's translation along the x, y, and z axes
  83823. */
  83824. translation?: number[];
  83825. /**
  83826. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83827. */
  83828. weights?: number[];
  83829. }
  83830. /**
  83831. * Texture sampler properties for filtering and wrapping modes
  83832. */
  83833. interface ISampler extends IChildRootProperty {
  83834. /**
  83835. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83836. */
  83837. magFilter?: TextureMagFilter;
  83838. /**
  83839. * Minification filter. All valid values correspond to WebGL enums
  83840. */
  83841. minFilter?: TextureMinFilter;
  83842. /**
  83843. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83844. */
  83845. wrapS?: TextureWrapMode;
  83846. /**
  83847. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83848. */
  83849. wrapT?: TextureWrapMode;
  83850. }
  83851. /**
  83852. * The root nodes of a scene
  83853. */
  83854. interface IScene extends IChildRootProperty {
  83855. /**
  83856. * The indices of each root node
  83857. */
  83858. nodes: number[];
  83859. }
  83860. /**
  83861. * Joints and matrices defining a skin
  83862. */
  83863. interface ISkin extends IChildRootProperty {
  83864. /**
  83865. * 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
  83866. */
  83867. inverseBindMatrices?: number;
  83868. /**
  83869. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83870. */
  83871. skeleton?: number;
  83872. /**
  83873. * 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)
  83874. */
  83875. joints: number[];
  83876. }
  83877. /**
  83878. * A texture and its sampler
  83879. */
  83880. interface ITexture extends IChildRootProperty {
  83881. /**
  83882. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83883. */
  83884. sampler?: number;
  83885. /**
  83886. * The index of the image used by this texture
  83887. */
  83888. source: number;
  83889. }
  83890. /**
  83891. * Reference to a texture
  83892. */
  83893. interface ITextureInfo extends IProperty {
  83894. /**
  83895. * The index of the texture
  83896. */
  83897. index: number;
  83898. /**
  83899. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83900. */
  83901. texCoord?: number;
  83902. }
  83903. /**
  83904. * The root object for a glTF asset
  83905. */
  83906. interface IGLTF extends IProperty {
  83907. /**
  83908. * An array of accessors. An accessor is a typed view into a bufferView
  83909. */
  83910. accessors?: IAccessor[];
  83911. /**
  83912. * An array of keyframe animations
  83913. */
  83914. animations?: IAnimation[];
  83915. /**
  83916. * Metadata about the glTF asset
  83917. */
  83918. asset: IAsset;
  83919. /**
  83920. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83921. */
  83922. buffers?: IBuffer[];
  83923. /**
  83924. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83925. */
  83926. bufferViews?: IBufferView[];
  83927. /**
  83928. * An array of cameras
  83929. */
  83930. cameras?: ICamera[];
  83931. /**
  83932. * Names of glTF extensions used somewhere in this asset
  83933. */
  83934. extensionsUsed?: string[];
  83935. /**
  83936. * Names of glTF extensions required to properly load this asset
  83937. */
  83938. extensionsRequired?: string[];
  83939. /**
  83940. * An array of images. An image defines data used to create a texture
  83941. */
  83942. images?: IImage[];
  83943. /**
  83944. * An array of materials. A material defines the appearance of a primitive
  83945. */
  83946. materials?: IMaterial[];
  83947. /**
  83948. * An array of meshes. A mesh is a set of primitives to be rendered
  83949. */
  83950. meshes?: IMesh[];
  83951. /**
  83952. * An array of nodes
  83953. */
  83954. nodes?: INode[];
  83955. /**
  83956. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83957. */
  83958. samplers?: ISampler[];
  83959. /**
  83960. * The index of the default scene
  83961. */
  83962. scene?: number;
  83963. /**
  83964. * An array of scenes
  83965. */
  83966. scenes?: IScene[];
  83967. /**
  83968. * An array of skins. A skin is defined by joints and matrices
  83969. */
  83970. skins?: ISkin[];
  83971. /**
  83972. * An array of textures
  83973. */
  83974. textures?: ITexture[];
  83975. }
  83976. /**
  83977. * The glTF validation results
  83978. * @ignore
  83979. */
  83980. interface IGLTFValidationResults {
  83981. info: {
  83982. generator: string;
  83983. hasAnimations: boolean;
  83984. hasDefaultScene: boolean;
  83985. hasMaterials: boolean;
  83986. hasMorphTargets: boolean;
  83987. hasSkins: boolean;
  83988. hasTextures: boolean;
  83989. maxAttributesUsed: number;
  83990. primitivesCount: number
  83991. };
  83992. issues: {
  83993. messages: Array<string>;
  83994. numErrors: number;
  83995. numHints: number;
  83996. numInfos: number;
  83997. numWarnings: number;
  83998. truncated: boolean
  83999. };
  84000. mimeType: string;
  84001. uri: string;
  84002. validatedAt: string;
  84003. validatorVersion: string;
  84004. }
  84005. /**
  84006. * The glTF validation options
  84007. */
  84008. interface IGLTFValidationOptions {
  84009. /** Uri to use */
  84010. uri?: string;
  84011. /** Function used to load external resources */
  84012. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84013. /** Boolean indicating that we need to validate accessor data */
  84014. validateAccessorData?: boolean;
  84015. /** max number of issues allowed */
  84016. maxIssues?: number;
  84017. /** Ignored issues */
  84018. ignoredIssues?: Array<string>;
  84019. /** Value to override severy settings */
  84020. severityOverrides?: Object;
  84021. }
  84022. /**
  84023. * The glTF validator object
  84024. * @ignore
  84025. */
  84026. interface IGLTFValidator {
  84027. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84028. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84029. }
  84030. /**
  84031. * Interfaces from the EXT_lights_image_based extension
  84032. */
  84033. /** @hidden */
  84034. interface IEXTLightsImageBased_LightReferenceImageBased {
  84035. light: number;
  84036. }
  84037. /** @hidden */
  84038. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84039. intensity: number;
  84040. rotation: number[];
  84041. specularImageSize: number;
  84042. specularImages: number[][];
  84043. irradianceCoefficients: number[][];
  84044. }
  84045. /** @hidden */
  84046. interface IEXTLightsImageBased {
  84047. lights: IEXTLightsImageBased_LightImageBased[];
  84048. }
  84049. /**
  84050. * Interfaces from the EXT_mesh_gpu_instancing extension
  84051. * !!! Experimental Extension Subject to Changes !!!
  84052. */
  84053. /** @hidden */
  84054. interface IEXTMeshGpuInstancing {
  84055. mesh?: number;
  84056. attributes: { [name: string]: number };
  84057. }
  84058. /**
  84059. * Interfaces from the KHR_draco_mesh_compression extension
  84060. */
  84061. /** @hidden */
  84062. interface IKHRDracoMeshCompression {
  84063. bufferView: number;
  84064. attributes: { [name: string]: number };
  84065. }
  84066. /**
  84067. * Interfaces from the KHR_lights_punctual extension
  84068. */
  84069. /** @hidden */
  84070. const enum IKHRLightsPunctual_LightType {
  84071. DIRECTIONAL = "directional",
  84072. POINT = "point",
  84073. SPOT = "spot"
  84074. }
  84075. /** @hidden */
  84076. interface IKHRLightsPunctual_LightReference {
  84077. light: number;
  84078. }
  84079. /** @hidden */
  84080. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84081. type: IKHRLightsPunctual_LightType;
  84082. color?: number[];
  84083. intensity?: number;
  84084. range?: number;
  84085. spot?: {
  84086. innerConeAngle?: number;
  84087. outerConeAngle?: number;
  84088. };
  84089. }
  84090. /** @hidden */
  84091. interface IKHRLightsPunctual {
  84092. lights: IKHRLightsPunctual_Light[];
  84093. }
  84094. /**
  84095. * Interfaces from the KHR_materials_clearcoat extension
  84096. * !!! Experimental Extension Subject to Changes !!!
  84097. */
  84098. /** @hidden */
  84099. interface IKHRMaterialsClearcoat {
  84100. clearcoatFactor: number;
  84101. clearcoatTexture: ITextureInfo;
  84102. clearcoatRoughnessFactor: number;
  84103. clearcoatRoughnessTexture: ITextureInfo;
  84104. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84105. }
  84106. /**
  84107. * Interfaces from the KHR_materials_ior extension
  84108. * !!! Experimental Extension Subject to Changes !!!
  84109. */
  84110. /** @hidden */
  84111. interface IKHRMaterialsIor {
  84112. ior: number;
  84113. }
  84114. /**
  84115. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84116. */
  84117. /** @hidden */
  84118. interface IKHRMaterialsPbrSpecularGlossiness {
  84119. diffuseFactor: number[];
  84120. diffuseTexture: ITextureInfo;
  84121. specularFactor: number[];
  84122. glossinessFactor: number;
  84123. specularGlossinessTexture: ITextureInfo;
  84124. }
  84125. /**
  84126. * Interfaces from the KHR_materials_sheen extension
  84127. * !!! Experimental Extension Subject to Changes !!!
  84128. */
  84129. /** @hidden */
  84130. interface IKHRMaterialsSheen {
  84131. sheenColorFactor?: number[];
  84132. sheenTexture?: ITextureInfo;
  84133. sheenRoughnessFactor?: number;
  84134. }
  84135. /**
  84136. * Interfaces from the KHR_materials_specular extension
  84137. * !!! Experimental Extension Subject to Changes !!!
  84138. */
  84139. /** @hidden */
  84140. interface IKHRMaterialsSpecular {
  84141. specularFactor: number;
  84142. specularColorFactor: number[];
  84143. specularTexture: ITextureInfo;
  84144. }
  84145. /**
  84146. * Interfaces from the KHR_materials_transmission extension
  84147. * !!! Experimental Extension Subject to Changes !!!
  84148. */
  84149. /** @hidden */
  84150. interface IKHRMaterialsTransmission {
  84151. transmissionFactor?: number;
  84152. transmissionTexture?: ITextureInfo;
  84153. }
  84154. /**
  84155. * Interfaces from the KHR_materials_variants extension
  84156. * !!! Experimental Extension Subject to Changes !!!
  84157. */
  84158. /** @hidden */
  84159. interface IKHRMaterialVariants_Mapping {
  84160. variants: string[];
  84161. material: number;
  84162. }
  84163. /** @hidden */
  84164. interface IKHRMaterialVariants {
  84165. mapping: IKHRMaterialVariants_Mapping[];
  84166. }
  84167. /**
  84168. * Interfaces from the KHR_texture_basisu extension
  84169. * !!! Experimental Extension Subject to Changes !!!
  84170. */
  84171. /** @hidden */
  84172. interface IKHRTextureBasisU {
  84173. source: number;
  84174. }
  84175. /**
  84176. * Interfaces from the KHR_texture_transform extension
  84177. */
  84178. /** @hidden */
  84179. interface IKHRTextureTransform {
  84180. offset?: number[];
  84181. rotation?: number;
  84182. scale?: number[];
  84183. texCoord?: number;
  84184. }
  84185. /**
  84186. * Interfaces from the KHR_xmp extension
  84187. * !!! Experimental Extension Subject to Changes !!!
  84188. */
  84189. /** @hidden */
  84190. interface IKHRXmp_Data {
  84191. [key: string]: unknown;
  84192. }
  84193. /** @hidden */
  84194. interface IKHRXmp_Gltf {
  84195. packets: IKHRXmp_Data[];
  84196. }
  84197. /** @hidden */
  84198. interface IKHRXmp_Node {
  84199. packet: number;
  84200. }
  84201. /**
  84202. * Interfaces from the MSFT_audio_emitter extension
  84203. */
  84204. /** @hidden */
  84205. interface IMSFTAudioEmitter_ClipReference {
  84206. clip: number;
  84207. weight?: number;
  84208. }
  84209. /** @hidden */
  84210. interface IMSFTAudioEmitter_EmittersReference {
  84211. emitters: number[];
  84212. }
  84213. /** @hidden */
  84214. const enum IMSFTAudioEmitter_DistanceModel {
  84215. linear = "linear",
  84216. inverse = "inverse",
  84217. exponential = "exponential",
  84218. }
  84219. /** @hidden */
  84220. interface IMSFTAudioEmitter_Emitter {
  84221. name?: string;
  84222. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84223. refDistance?: number;
  84224. maxDistance?: number;
  84225. rolloffFactor?: number;
  84226. innerAngle?: number;
  84227. outerAngle?: number;
  84228. loop?: boolean;
  84229. volume?: number;
  84230. clips: IMSFTAudioEmitter_ClipReference[];
  84231. }
  84232. /** @hidden */
  84233. const enum IMSFTAudioEmitter_AudioMimeType {
  84234. WAV = "audio/wav",
  84235. }
  84236. /** @hidden */
  84237. interface IMSFTAudioEmitter_Clip extends IProperty {
  84238. uri?: string;
  84239. bufferView?: number;
  84240. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84241. }
  84242. /** @hidden */
  84243. const enum IMSFTAudioEmitter_AnimationEventAction {
  84244. play = "play",
  84245. pause = "pause",
  84246. stop = "stop",
  84247. }
  84248. /** @hidden */
  84249. interface IMSFTAudioEmitter_AnimationEvent {
  84250. action: IMSFTAudioEmitter_AnimationEventAction;
  84251. emitter: number;
  84252. time: number;
  84253. startOffset?: number;
  84254. }
  84255. /**
  84256. * Interfaces from the MSFT_lod extension
  84257. */
  84258. /** @hidden */
  84259. interface IMSFTLOD {
  84260. ids: number[];
  84261. }
  84262. }
  84263. declare module BABYLON {
  84264. /** @hidden */
  84265. export var cellPixelShader: {
  84266. name: string;
  84267. shader: string;
  84268. };
  84269. }
  84270. declare module BABYLON {
  84271. /** @hidden */
  84272. export var cellVertexShader: {
  84273. name: string;
  84274. shader: string;
  84275. };
  84276. }
  84277. declare module BABYLON {
  84278. export class CellMaterial extends BABYLON.PushMaterial {
  84279. private _diffuseTexture;
  84280. diffuseTexture: BABYLON.BaseTexture;
  84281. diffuseColor: BABYLON.Color3;
  84282. _computeHighLevel: boolean;
  84283. computeHighLevel: boolean;
  84284. private _disableLighting;
  84285. disableLighting: boolean;
  84286. private _maxSimultaneousLights;
  84287. maxSimultaneousLights: number;
  84288. constructor(name: string, scene: BABYLON.Scene);
  84289. needAlphaBlending(): boolean;
  84290. needAlphaTesting(): boolean;
  84291. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84292. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84293. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84294. getAnimatables(): BABYLON.IAnimatable[];
  84295. getActiveTextures(): BABYLON.BaseTexture[];
  84296. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84297. dispose(forceDisposeEffect?: boolean): void;
  84298. getClassName(): string;
  84299. clone(name: string): CellMaterial;
  84300. serialize(): any;
  84301. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84302. }
  84303. }
  84304. declare module BABYLON {
  84305. export class CustomShaderStructure {
  84306. FragmentStore: string;
  84307. VertexStore: string;
  84308. constructor();
  84309. }
  84310. export class ShaderSpecialParts {
  84311. constructor();
  84312. Fragment_Begin: string;
  84313. Fragment_Definitions: string;
  84314. Fragment_MainBegin: string;
  84315. Fragment_Custom_Diffuse: string;
  84316. Fragment_Before_Lights: string;
  84317. Fragment_Before_Fog: string;
  84318. Fragment_Custom_Alpha: string;
  84319. Fragment_Before_FragColor: string;
  84320. Vertex_Begin: string;
  84321. Vertex_Definitions: string;
  84322. Vertex_MainBegin: string;
  84323. Vertex_Before_PositionUpdated: string;
  84324. Vertex_Before_NormalUpdated: string;
  84325. Vertex_After_WorldPosComputed: string;
  84326. Vertex_MainEnd: string;
  84327. }
  84328. export class CustomMaterial extends BABYLON.StandardMaterial {
  84329. static ShaderIndexer: number;
  84330. CustomParts: ShaderSpecialParts;
  84331. _isCreatedShader: boolean;
  84332. _createdShaderName: string;
  84333. _customUniform: string[];
  84334. _newUniforms: string[];
  84335. _newUniformInstances: {
  84336. [name: string]: any;
  84337. };
  84338. _newSamplerInstances: {
  84339. [name: string]: BABYLON.Texture;
  84340. };
  84341. _customAttributes: string[];
  84342. FragmentShader: string;
  84343. VertexShader: string;
  84344. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84345. ReviewUniform(name: string, arr: string[]): string[];
  84346. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84347. constructor(name: string, scene: BABYLON.Scene);
  84348. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84349. AddAttribute(name: string): CustomMaterial;
  84350. Fragment_Begin(shaderPart: string): CustomMaterial;
  84351. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84352. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84353. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84354. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84355. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84356. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84357. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84358. Vertex_Begin(shaderPart: string): CustomMaterial;
  84359. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84360. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84361. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84362. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84363. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84364. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84365. }
  84366. }
  84367. declare module BABYLON {
  84368. export class ShaderAlebdoParts {
  84369. constructor();
  84370. Fragment_Begin: string;
  84371. Fragment_Definitions: string;
  84372. Fragment_MainBegin: string;
  84373. Fragment_Custom_Albedo: string;
  84374. Fragment_Before_Lights: string;
  84375. Fragment_Custom_MetallicRoughness: string;
  84376. Fragment_Custom_MicroSurface: string;
  84377. Fragment_Before_Fog: string;
  84378. Fragment_Custom_Alpha: string;
  84379. Fragment_Before_FragColor: string;
  84380. Vertex_Begin: string;
  84381. Vertex_Definitions: string;
  84382. Vertex_MainBegin: string;
  84383. Vertex_Before_PositionUpdated: string;
  84384. Vertex_Before_NormalUpdated: string;
  84385. Vertex_After_WorldPosComputed: string;
  84386. Vertex_MainEnd: string;
  84387. }
  84388. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84389. static ShaderIndexer: number;
  84390. CustomParts: ShaderAlebdoParts;
  84391. _isCreatedShader: boolean;
  84392. _createdShaderName: string;
  84393. _customUniform: string[];
  84394. _newUniforms: string[];
  84395. _newUniformInstances: {
  84396. [name: string]: any;
  84397. };
  84398. _newSamplerInstances: {
  84399. [name: string]: BABYLON.Texture;
  84400. };
  84401. _customAttributes: string[];
  84402. FragmentShader: string;
  84403. VertexShader: string;
  84404. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84405. ReviewUniform(name: string, arr: string[]): string[];
  84406. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84407. constructor(name: string, scene: BABYLON.Scene);
  84408. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84409. AddAttribute(name: string): PBRCustomMaterial;
  84410. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84411. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84412. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84413. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84414. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84415. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84416. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84417. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84418. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84419. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84420. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84421. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84422. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84423. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84424. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84425. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84426. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84427. }
  84428. }
  84429. declare module BABYLON {
  84430. /** @hidden */
  84431. export var firePixelShader: {
  84432. name: string;
  84433. shader: string;
  84434. };
  84435. }
  84436. declare module BABYLON {
  84437. /** @hidden */
  84438. export var fireVertexShader: {
  84439. name: string;
  84440. shader: string;
  84441. };
  84442. }
  84443. declare module BABYLON {
  84444. export class FireMaterial extends BABYLON.PushMaterial {
  84445. private _diffuseTexture;
  84446. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84447. private _distortionTexture;
  84448. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84449. private _opacityTexture;
  84450. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84451. diffuseColor: BABYLON.Color3;
  84452. speed: number;
  84453. private _scaledDiffuse;
  84454. private _lastTime;
  84455. constructor(name: string, scene: BABYLON.Scene);
  84456. needAlphaBlending(): boolean;
  84457. needAlphaTesting(): boolean;
  84458. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84459. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84460. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84461. getAnimatables(): BABYLON.IAnimatable[];
  84462. getActiveTextures(): BABYLON.BaseTexture[];
  84463. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84464. getClassName(): string;
  84465. dispose(forceDisposeEffect?: boolean): void;
  84466. clone(name: string): FireMaterial;
  84467. serialize(): any;
  84468. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84469. }
  84470. }
  84471. declare module BABYLON {
  84472. /** @hidden */
  84473. export var furPixelShader: {
  84474. name: string;
  84475. shader: string;
  84476. };
  84477. }
  84478. declare module BABYLON {
  84479. /** @hidden */
  84480. export var furVertexShader: {
  84481. name: string;
  84482. shader: string;
  84483. };
  84484. }
  84485. declare module BABYLON {
  84486. export class FurMaterial extends BABYLON.PushMaterial {
  84487. private _diffuseTexture;
  84488. diffuseTexture: BABYLON.BaseTexture;
  84489. private _heightTexture;
  84490. heightTexture: BABYLON.BaseTexture;
  84491. diffuseColor: BABYLON.Color3;
  84492. furLength: number;
  84493. furAngle: number;
  84494. furColor: BABYLON.Color3;
  84495. furOffset: number;
  84496. furSpacing: number;
  84497. furGravity: BABYLON.Vector3;
  84498. furSpeed: number;
  84499. furDensity: number;
  84500. furOcclusion: number;
  84501. furTexture: BABYLON.DynamicTexture;
  84502. private _disableLighting;
  84503. disableLighting: boolean;
  84504. private _maxSimultaneousLights;
  84505. maxSimultaneousLights: number;
  84506. highLevelFur: boolean;
  84507. _meshes: BABYLON.AbstractMesh[];
  84508. private _furTime;
  84509. constructor(name: string, scene: BABYLON.Scene);
  84510. get furTime(): number;
  84511. set furTime(furTime: number);
  84512. needAlphaBlending(): boolean;
  84513. needAlphaTesting(): boolean;
  84514. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84515. updateFur(): void;
  84516. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84517. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84518. getAnimatables(): BABYLON.IAnimatable[];
  84519. getActiveTextures(): BABYLON.BaseTexture[];
  84520. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84521. dispose(forceDisposeEffect?: boolean): void;
  84522. clone(name: string): FurMaterial;
  84523. serialize(): any;
  84524. getClassName(): string;
  84525. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84526. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84527. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84528. }
  84529. }
  84530. declare module BABYLON {
  84531. /** @hidden */
  84532. export var gradientPixelShader: {
  84533. name: string;
  84534. shader: string;
  84535. };
  84536. }
  84537. declare module BABYLON {
  84538. /** @hidden */
  84539. export var gradientVertexShader: {
  84540. name: string;
  84541. shader: string;
  84542. };
  84543. }
  84544. declare module BABYLON {
  84545. export class GradientMaterial extends BABYLON.PushMaterial {
  84546. private _maxSimultaneousLights;
  84547. maxSimultaneousLights: number;
  84548. topColor: BABYLON.Color3;
  84549. topColorAlpha: number;
  84550. bottomColor: BABYLON.Color3;
  84551. bottomColorAlpha: number;
  84552. offset: number;
  84553. scale: number;
  84554. smoothness: number;
  84555. private _disableLighting;
  84556. disableLighting: boolean;
  84557. constructor(name: string, scene: BABYLON.Scene);
  84558. needAlphaBlending(): boolean;
  84559. needAlphaTesting(): boolean;
  84560. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84561. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84562. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84563. getAnimatables(): BABYLON.IAnimatable[];
  84564. dispose(forceDisposeEffect?: boolean): void;
  84565. clone(name: string): GradientMaterial;
  84566. serialize(): any;
  84567. getClassName(): string;
  84568. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84569. }
  84570. }
  84571. declare module BABYLON {
  84572. /** @hidden */
  84573. export var gridPixelShader: {
  84574. name: string;
  84575. shader: string;
  84576. };
  84577. }
  84578. declare module BABYLON {
  84579. /** @hidden */
  84580. export var gridVertexShader: {
  84581. name: string;
  84582. shader: string;
  84583. };
  84584. }
  84585. declare module BABYLON {
  84586. /**
  84587. * The grid materials allows you to wrap any shape with a grid.
  84588. * Colors are customizable.
  84589. */
  84590. export class GridMaterial extends BABYLON.PushMaterial {
  84591. /**
  84592. * Main color of the grid (e.g. between lines)
  84593. */
  84594. mainColor: BABYLON.Color3;
  84595. /**
  84596. * Color of the grid lines.
  84597. */
  84598. lineColor: BABYLON.Color3;
  84599. /**
  84600. * The scale of the grid compared to unit.
  84601. */
  84602. gridRatio: number;
  84603. /**
  84604. * Allows setting an offset for the grid lines.
  84605. */
  84606. gridOffset: BABYLON.Vector3;
  84607. /**
  84608. * The frequency of thicker lines.
  84609. */
  84610. majorUnitFrequency: number;
  84611. /**
  84612. * The visibility of minor units in the grid.
  84613. */
  84614. minorUnitVisibility: number;
  84615. /**
  84616. * The grid opacity outside of the lines.
  84617. */
  84618. opacity: number;
  84619. /**
  84620. * Determine RBG output is premultiplied by alpha value.
  84621. */
  84622. preMultiplyAlpha: boolean;
  84623. private _opacityTexture;
  84624. opacityTexture: BABYLON.BaseTexture;
  84625. private _gridControl;
  84626. /**
  84627. * constructor
  84628. * @param name The name given to the material in order to identify it afterwards.
  84629. * @param scene The scene the material is used in.
  84630. */
  84631. constructor(name: string, scene: BABYLON.Scene);
  84632. /**
  84633. * Returns wehter or not the grid requires alpha blending.
  84634. */
  84635. needAlphaBlending(): boolean;
  84636. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84637. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84638. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84639. /**
  84640. * Dispose the material and its associated resources.
  84641. * @param forceDisposeEffect will also dispose the used effect when true
  84642. */
  84643. dispose(forceDisposeEffect?: boolean): void;
  84644. clone(name: string): GridMaterial;
  84645. serialize(): any;
  84646. getClassName(): string;
  84647. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84648. }
  84649. }
  84650. declare module BABYLON {
  84651. /** @hidden */
  84652. export var lavaPixelShader: {
  84653. name: string;
  84654. shader: string;
  84655. };
  84656. }
  84657. declare module BABYLON {
  84658. /** @hidden */
  84659. export var lavaVertexShader: {
  84660. name: string;
  84661. shader: string;
  84662. };
  84663. }
  84664. declare module BABYLON {
  84665. export class LavaMaterial extends BABYLON.PushMaterial {
  84666. private _diffuseTexture;
  84667. diffuseTexture: BABYLON.BaseTexture;
  84668. noiseTexture: BABYLON.BaseTexture;
  84669. fogColor: BABYLON.Color3;
  84670. speed: number;
  84671. movingSpeed: number;
  84672. lowFrequencySpeed: number;
  84673. fogDensity: number;
  84674. private _lastTime;
  84675. diffuseColor: BABYLON.Color3;
  84676. private _disableLighting;
  84677. disableLighting: boolean;
  84678. private _unlit;
  84679. unlit: boolean;
  84680. private _maxSimultaneousLights;
  84681. maxSimultaneousLights: number;
  84682. private _scaledDiffuse;
  84683. constructor(name: string, scene: BABYLON.Scene);
  84684. needAlphaBlending(): boolean;
  84685. needAlphaTesting(): boolean;
  84686. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84687. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84688. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84689. getAnimatables(): BABYLON.IAnimatable[];
  84690. getActiveTextures(): BABYLON.BaseTexture[];
  84691. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84692. dispose(forceDisposeEffect?: boolean): void;
  84693. clone(name: string): LavaMaterial;
  84694. serialize(): any;
  84695. getClassName(): string;
  84696. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84697. }
  84698. }
  84699. declare module BABYLON {
  84700. /** @hidden */
  84701. export var mixPixelShader: {
  84702. name: string;
  84703. shader: string;
  84704. };
  84705. }
  84706. declare module BABYLON {
  84707. /** @hidden */
  84708. export var mixVertexShader: {
  84709. name: string;
  84710. shader: string;
  84711. };
  84712. }
  84713. declare module BABYLON {
  84714. export class MixMaterial extends BABYLON.PushMaterial {
  84715. /**
  84716. * Mix textures
  84717. */
  84718. private _mixTexture1;
  84719. mixTexture1: BABYLON.BaseTexture;
  84720. private _mixTexture2;
  84721. mixTexture2: BABYLON.BaseTexture;
  84722. /**
  84723. * Diffuse textures
  84724. */
  84725. private _diffuseTexture1;
  84726. diffuseTexture1: BABYLON.Texture;
  84727. private _diffuseTexture2;
  84728. diffuseTexture2: BABYLON.Texture;
  84729. private _diffuseTexture3;
  84730. diffuseTexture3: BABYLON.Texture;
  84731. private _diffuseTexture4;
  84732. diffuseTexture4: BABYLON.Texture;
  84733. private _diffuseTexture5;
  84734. diffuseTexture5: BABYLON.Texture;
  84735. private _diffuseTexture6;
  84736. diffuseTexture6: BABYLON.Texture;
  84737. private _diffuseTexture7;
  84738. diffuseTexture7: BABYLON.Texture;
  84739. private _diffuseTexture8;
  84740. diffuseTexture8: BABYLON.Texture;
  84741. /**
  84742. * Uniforms
  84743. */
  84744. diffuseColor: BABYLON.Color3;
  84745. specularColor: BABYLON.Color3;
  84746. specularPower: number;
  84747. private _disableLighting;
  84748. disableLighting: boolean;
  84749. private _maxSimultaneousLights;
  84750. maxSimultaneousLights: number;
  84751. constructor(name: string, scene: BABYLON.Scene);
  84752. needAlphaBlending(): boolean;
  84753. needAlphaTesting(): boolean;
  84754. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84755. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84756. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84757. getAnimatables(): BABYLON.IAnimatable[];
  84758. getActiveTextures(): BABYLON.BaseTexture[];
  84759. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84760. dispose(forceDisposeEffect?: boolean): void;
  84761. clone(name: string): MixMaterial;
  84762. serialize(): any;
  84763. getClassName(): string;
  84764. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84765. }
  84766. }
  84767. declare module BABYLON {
  84768. /** @hidden */
  84769. export var normalPixelShader: {
  84770. name: string;
  84771. shader: string;
  84772. };
  84773. }
  84774. declare module BABYLON {
  84775. /** @hidden */
  84776. export var normalVertexShader: {
  84777. name: string;
  84778. shader: string;
  84779. };
  84780. }
  84781. declare module BABYLON {
  84782. export class NormalMaterial extends BABYLON.PushMaterial {
  84783. private _diffuseTexture;
  84784. diffuseTexture: BABYLON.BaseTexture;
  84785. diffuseColor: BABYLON.Color3;
  84786. private _disableLighting;
  84787. disableLighting: boolean;
  84788. private _maxSimultaneousLights;
  84789. maxSimultaneousLights: number;
  84790. constructor(name: string, scene: BABYLON.Scene);
  84791. needAlphaBlending(): boolean;
  84792. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84793. needAlphaTesting(): boolean;
  84794. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84795. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84796. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84797. getAnimatables(): BABYLON.IAnimatable[];
  84798. getActiveTextures(): BABYLON.BaseTexture[];
  84799. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84800. dispose(forceDisposeEffect?: boolean): void;
  84801. clone(name: string): NormalMaterial;
  84802. serialize(): any;
  84803. getClassName(): string;
  84804. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84805. }
  84806. }
  84807. declare module BABYLON {
  84808. /** @hidden */
  84809. export var shadowOnlyPixelShader: {
  84810. name: string;
  84811. shader: string;
  84812. };
  84813. }
  84814. declare module BABYLON {
  84815. /** @hidden */
  84816. export var shadowOnlyVertexShader: {
  84817. name: string;
  84818. shader: string;
  84819. };
  84820. }
  84821. declare module BABYLON {
  84822. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84823. private _activeLight;
  84824. private _needAlphaBlending;
  84825. constructor(name: string, scene: BABYLON.Scene);
  84826. shadowColor: BABYLON.Color3;
  84827. needAlphaBlending(): boolean;
  84828. needAlphaTesting(): boolean;
  84829. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84830. get activeLight(): BABYLON.IShadowLight;
  84831. set activeLight(light: BABYLON.IShadowLight);
  84832. private _getFirstShadowLightForMesh;
  84833. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84834. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84835. clone(name: string): ShadowOnlyMaterial;
  84836. serialize(): any;
  84837. getClassName(): string;
  84838. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84839. }
  84840. }
  84841. declare module BABYLON {
  84842. /** @hidden */
  84843. export var simplePixelShader: {
  84844. name: string;
  84845. shader: string;
  84846. };
  84847. }
  84848. declare module BABYLON {
  84849. /** @hidden */
  84850. export var simpleVertexShader: {
  84851. name: string;
  84852. shader: string;
  84853. };
  84854. }
  84855. declare module BABYLON {
  84856. export class SimpleMaterial extends BABYLON.PushMaterial {
  84857. private _diffuseTexture;
  84858. diffuseTexture: BABYLON.BaseTexture;
  84859. diffuseColor: BABYLON.Color3;
  84860. private _disableLighting;
  84861. disableLighting: boolean;
  84862. private _maxSimultaneousLights;
  84863. maxSimultaneousLights: number;
  84864. constructor(name: string, scene: BABYLON.Scene);
  84865. needAlphaBlending(): boolean;
  84866. needAlphaTesting(): boolean;
  84867. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84868. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84869. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84870. getAnimatables(): BABYLON.IAnimatable[];
  84871. getActiveTextures(): BABYLON.BaseTexture[];
  84872. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84873. dispose(forceDisposeEffect?: boolean): void;
  84874. clone(name: string): SimpleMaterial;
  84875. serialize(): any;
  84876. getClassName(): string;
  84877. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84878. }
  84879. }
  84880. declare module BABYLON {
  84881. /** @hidden */
  84882. export var skyPixelShader: {
  84883. name: string;
  84884. shader: string;
  84885. };
  84886. }
  84887. declare module BABYLON {
  84888. /** @hidden */
  84889. export var skyVertexShader: {
  84890. name: string;
  84891. shader: string;
  84892. };
  84893. }
  84894. declare module BABYLON {
  84895. /**
  84896. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84897. * @see https://doc.babylonjs.com/extensions/sky
  84898. */
  84899. export class SkyMaterial extends BABYLON.PushMaterial {
  84900. /**
  84901. * Defines the overall luminance of sky in interval ]0, 1[.
  84902. */
  84903. luminance: number;
  84904. /**
  84905. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84906. */
  84907. turbidity: number;
  84908. /**
  84909. * Defines the sky appearance (light intensity).
  84910. */
  84911. rayleigh: number;
  84912. /**
  84913. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84914. */
  84915. mieCoefficient: number;
  84916. /**
  84917. * Defines the amount of haze particles following the Mie scattering theory.
  84918. */
  84919. mieDirectionalG: number;
  84920. /**
  84921. * Defines the distance of the sun according to the active scene camera.
  84922. */
  84923. distance: number;
  84924. /**
  84925. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84926. * "inclined".
  84927. */
  84928. inclination: number;
  84929. /**
  84930. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84931. * an object direction and a reference direction.
  84932. */
  84933. azimuth: number;
  84934. /**
  84935. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84936. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84937. */
  84938. sunPosition: BABYLON.Vector3;
  84939. /**
  84940. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84941. * .sunPosition property.
  84942. */
  84943. useSunPosition: boolean;
  84944. /**
  84945. * Defines an offset vector used to get a horizon offset.
  84946. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84947. */
  84948. cameraOffset: BABYLON.Vector3;
  84949. private _cameraPosition;
  84950. /**
  84951. * Instantiates a new sky material.
  84952. * This material allows to create dynamic and texture free
  84953. * effects for skyboxes by taking care of the atmosphere state.
  84954. * @see https://doc.babylonjs.com/extensions/sky
  84955. * @param name Define the name of the material in the scene
  84956. * @param scene Define the scene the material belong to
  84957. */
  84958. constructor(name: string, scene: BABYLON.Scene);
  84959. /**
  84960. * Specifies if the material will require alpha blending
  84961. * @returns a boolean specifying if alpha blending is needed
  84962. */
  84963. needAlphaBlending(): boolean;
  84964. /**
  84965. * Specifies if this material should be rendered in alpha test mode
  84966. * @returns false as the sky material doesn't need alpha testing.
  84967. */
  84968. needAlphaTesting(): boolean;
  84969. /**
  84970. * Get the texture used for alpha test purpose.
  84971. * @returns null as the sky material has no texture.
  84972. */
  84973. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84974. /**
  84975. * Get if the submesh is ready to be used and all its information available.
  84976. * Child classes can use it to update shaders
  84977. * @param mesh defines the mesh to check
  84978. * @param subMesh defines which submesh to check
  84979. * @param useInstances specifies that instances should be used
  84980. * @returns a boolean indicating that the submesh is ready or not
  84981. */
  84982. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84983. /**
  84984. * Binds the submesh to this material by preparing the effect and shader to draw
  84985. * @param world defines the world transformation matrix
  84986. * @param mesh defines the mesh containing the submesh
  84987. * @param subMesh defines the submesh to bind the material to
  84988. */
  84989. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84990. /**
  84991. * Get the list of animatables in the material.
  84992. * @returns the list of animatables object used in the material
  84993. */
  84994. getAnimatables(): BABYLON.IAnimatable[];
  84995. /**
  84996. * Disposes the material
  84997. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84998. */
  84999. dispose(forceDisposeEffect?: boolean): void;
  85000. /**
  85001. * Makes a duplicate of the material, and gives it a new name
  85002. * @param name defines the new name for the duplicated material
  85003. * @returns the cloned material
  85004. */
  85005. clone(name: string): SkyMaterial;
  85006. /**
  85007. * Serializes this material in a JSON representation
  85008. * @returns the serialized material object
  85009. */
  85010. serialize(): any;
  85011. /**
  85012. * Gets the current class name of the material e.g. "SkyMaterial"
  85013. * Mainly use in serialization.
  85014. * @returns the class name
  85015. */
  85016. getClassName(): string;
  85017. /**
  85018. * Creates a sky material from parsed material data
  85019. * @param source defines the JSON representation of the material
  85020. * @param scene defines the hosting scene
  85021. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85022. * @returns a new sky material
  85023. */
  85024. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85025. }
  85026. }
  85027. declare module BABYLON {
  85028. /** @hidden */
  85029. export var terrainPixelShader: {
  85030. name: string;
  85031. shader: string;
  85032. };
  85033. }
  85034. declare module BABYLON {
  85035. /** @hidden */
  85036. export var terrainVertexShader: {
  85037. name: string;
  85038. shader: string;
  85039. };
  85040. }
  85041. declare module BABYLON {
  85042. export class TerrainMaterial extends BABYLON.PushMaterial {
  85043. private _mixTexture;
  85044. mixTexture: BABYLON.BaseTexture;
  85045. private _diffuseTexture1;
  85046. diffuseTexture1: BABYLON.Texture;
  85047. private _diffuseTexture2;
  85048. diffuseTexture2: BABYLON.Texture;
  85049. private _diffuseTexture3;
  85050. diffuseTexture3: BABYLON.Texture;
  85051. private _bumpTexture1;
  85052. bumpTexture1: BABYLON.Texture;
  85053. private _bumpTexture2;
  85054. bumpTexture2: BABYLON.Texture;
  85055. private _bumpTexture3;
  85056. bumpTexture3: BABYLON.Texture;
  85057. diffuseColor: BABYLON.Color3;
  85058. specularColor: BABYLON.Color3;
  85059. specularPower: number;
  85060. private _disableLighting;
  85061. disableLighting: boolean;
  85062. private _maxSimultaneousLights;
  85063. maxSimultaneousLights: number;
  85064. constructor(name: string, scene: BABYLON.Scene);
  85065. needAlphaBlending(): boolean;
  85066. needAlphaTesting(): boolean;
  85067. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85068. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85069. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85070. getAnimatables(): BABYLON.IAnimatable[];
  85071. getActiveTextures(): BABYLON.BaseTexture[];
  85072. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85073. dispose(forceDisposeEffect?: boolean): void;
  85074. clone(name: string): TerrainMaterial;
  85075. serialize(): any;
  85076. getClassName(): string;
  85077. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85078. }
  85079. }
  85080. declare module BABYLON {
  85081. /** @hidden */
  85082. export var triplanarPixelShader: {
  85083. name: string;
  85084. shader: string;
  85085. };
  85086. }
  85087. declare module BABYLON {
  85088. /** @hidden */
  85089. export var triplanarVertexShader: {
  85090. name: string;
  85091. shader: string;
  85092. };
  85093. }
  85094. declare module BABYLON {
  85095. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85096. mixTexture: BABYLON.BaseTexture;
  85097. private _diffuseTextureX;
  85098. diffuseTextureX: BABYLON.BaseTexture;
  85099. private _diffuseTextureY;
  85100. diffuseTextureY: BABYLON.BaseTexture;
  85101. private _diffuseTextureZ;
  85102. diffuseTextureZ: BABYLON.BaseTexture;
  85103. private _normalTextureX;
  85104. normalTextureX: BABYLON.BaseTexture;
  85105. private _normalTextureY;
  85106. normalTextureY: BABYLON.BaseTexture;
  85107. private _normalTextureZ;
  85108. normalTextureZ: BABYLON.BaseTexture;
  85109. tileSize: number;
  85110. diffuseColor: BABYLON.Color3;
  85111. specularColor: BABYLON.Color3;
  85112. specularPower: number;
  85113. private _disableLighting;
  85114. disableLighting: boolean;
  85115. private _maxSimultaneousLights;
  85116. maxSimultaneousLights: number;
  85117. constructor(name: string, scene: BABYLON.Scene);
  85118. needAlphaBlending(): boolean;
  85119. needAlphaTesting(): boolean;
  85120. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85121. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85122. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85123. getAnimatables(): BABYLON.IAnimatable[];
  85124. getActiveTextures(): BABYLON.BaseTexture[];
  85125. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85126. dispose(forceDisposeEffect?: boolean): void;
  85127. clone(name: string): TriPlanarMaterial;
  85128. serialize(): any;
  85129. getClassName(): string;
  85130. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85131. }
  85132. }
  85133. declare module BABYLON {
  85134. /** @hidden */
  85135. export var waterPixelShader: {
  85136. name: string;
  85137. shader: string;
  85138. };
  85139. }
  85140. declare module BABYLON {
  85141. /** @hidden */
  85142. export var waterVertexShader: {
  85143. name: string;
  85144. shader: string;
  85145. };
  85146. }
  85147. declare module BABYLON {
  85148. export class WaterMaterial extends BABYLON.PushMaterial {
  85149. renderTargetSize: BABYLON.Vector2;
  85150. private _bumpTexture;
  85151. bumpTexture: BABYLON.BaseTexture;
  85152. diffuseColor: BABYLON.Color3;
  85153. specularColor: BABYLON.Color3;
  85154. specularPower: number;
  85155. private _disableLighting;
  85156. disableLighting: boolean;
  85157. private _maxSimultaneousLights;
  85158. maxSimultaneousLights: number;
  85159. /**
  85160. * @param {number}: Represents the wind force
  85161. */
  85162. windForce: number;
  85163. /**
  85164. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85165. */
  85166. windDirection: BABYLON.Vector2;
  85167. /**
  85168. * @param {number}: Wave height, represents the height of the waves
  85169. */
  85170. waveHeight: number;
  85171. /**
  85172. * @param {number}: Bump height, represents the bump height related to the bump map
  85173. */
  85174. bumpHeight: number;
  85175. /**
  85176. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85177. */
  85178. private _bumpSuperimpose;
  85179. bumpSuperimpose: boolean;
  85180. /**
  85181. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85182. */
  85183. private _fresnelSeparate;
  85184. fresnelSeparate: boolean;
  85185. /**
  85186. * @param {boolean}: bump Waves modify the reflection.
  85187. */
  85188. private _bumpAffectsReflection;
  85189. bumpAffectsReflection: boolean;
  85190. /**
  85191. * @param {number}: The water color blended with the refraction (near)
  85192. */
  85193. waterColor: BABYLON.Color3;
  85194. /**
  85195. * @param {number}: The blend factor related to the water color
  85196. */
  85197. colorBlendFactor: number;
  85198. /**
  85199. * @param {number}: The water color blended with the reflection (far)
  85200. */
  85201. waterColor2: BABYLON.Color3;
  85202. /**
  85203. * @param {number}: The blend factor related to the water color (reflection, far)
  85204. */
  85205. colorBlendFactor2: number;
  85206. /**
  85207. * @param {number}: Represents the maximum length of a wave
  85208. */
  85209. waveLength: number;
  85210. /**
  85211. * @param {number}: Defines the waves speed
  85212. */
  85213. waveSpeed: number;
  85214. /**
  85215. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85216. * will avoid calculating useless pixels in the pixel shader of the water material.
  85217. */
  85218. disableClipPlane: boolean;
  85219. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85220. private _mesh;
  85221. private _refractionRTT;
  85222. private _reflectionRTT;
  85223. private _reflectionTransform;
  85224. private _lastTime;
  85225. private _lastDeltaTime;
  85226. private _useLogarithmicDepth;
  85227. private _waitingRenderList;
  85228. private _imageProcessingConfiguration;
  85229. private _imageProcessingObserver;
  85230. /**
  85231. * Gets a boolean indicating that current material needs to register RTT
  85232. */
  85233. get hasRenderTargetTextures(): boolean;
  85234. /**
  85235. * Constructor
  85236. */
  85237. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85238. get useLogarithmicDepth(): boolean;
  85239. set useLogarithmicDepth(value: boolean);
  85240. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85241. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85242. addToRenderList(node: any): void;
  85243. enableRenderTargets(enable: boolean): void;
  85244. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85245. get renderTargetsEnabled(): boolean;
  85246. needAlphaBlending(): boolean;
  85247. needAlphaTesting(): boolean;
  85248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85251. private _createRenderTargets;
  85252. getAnimatables(): BABYLON.IAnimatable[];
  85253. getActiveTextures(): BABYLON.BaseTexture[];
  85254. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85255. dispose(forceDisposeEffect?: boolean): void;
  85256. clone(name: string): WaterMaterial;
  85257. serialize(): any;
  85258. getClassName(): string;
  85259. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85260. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85261. }
  85262. }
  85263. declare module BABYLON {
  85264. /** @hidden */
  85265. export var asciiartPixelShader: {
  85266. name: string;
  85267. shader: string;
  85268. };
  85269. }
  85270. declare module BABYLON {
  85271. /**
  85272. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85273. *
  85274. * It basically takes care rendering the font front the given font size to a texture.
  85275. * This is used later on in the postprocess.
  85276. */
  85277. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85278. private _font;
  85279. private _text;
  85280. private _charSize;
  85281. /**
  85282. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85283. */
  85284. get charSize(): number;
  85285. /**
  85286. * Create a new instance of the Ascii Art FontTexture class
  85287. * @param name the name of the texture
  85288. * @param font the font to use, use the W3C CSS notation
  85289. * @param text the caracter set to use in the rendering.
  85290. * @param scene the scene that owns the texture
  85291. */
  85292. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85293. /**
  85294. * Gets the max char width of a font.
  85295. * @param font the font to use, use the W3C CSS notation
  85296. * @return the max char width
  85297. */
  85298. private getFontWidth;
  85299. /**
  85300. * Gets the max char height of a font.
  85301. * @param font the font to use, use the W3C CSS notation
  85302. * @return the max char height
  85303. */
  85304. private getFontHeight;
  85305. /**
  85306. * Clones the current AsciiArtTexture.
  85307. * @return the clone of the texture.
  85308. */
  85309. clone(): AsciiArtFontTexture;
  85310. /**
  85311. * Parses a json object representing the texture and returns an instance of it.
  85312. * @param source the source JSON representation
  85313. * @param scene the scene to create the texture for
  85314. * @return the parsed texture
  85315. */
  85316. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85317. }
  85318. /**
  85319. * Option available in the Ascii Art Post Process.
  85320. */
  85321. export interface IAsciiArtPostProcessOptions {
  85322. /**
  85323. * The font to use following the w3c font definition.
  85324. */
  85325. font?: string;
  85326. /**
  85327. * The character set to use in the postprocess.
  85328. */
  85329. characterSet?: string;
  85330. /**
  85331. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85332. * This number is defined between 0 and 1;
  85333. */
  85334. mixToTile?: number;
  85335. /**
  85336. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85337. * This number is defined between 0 and 1;
  85338. */
  85339. mixToNormal?: number;
  85340. }
  85341. /**
  85342. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85343. *
  85344. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85345. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85346. */
  85347. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85348. /**
  85349. * The font texture used to render the char in the post process.
  85350. */
  85351. private _asciiArtFontTexture;
  85352. /**
  85353. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85354. * This number is defined between 0 and 1;
  85355. */
  85356. mixToTile: number;
  85357. /**
  85358. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85359. * This number is defined between 0 and 1;
  85360. */
  85361. mixToNormal: number;
  85362. /**
  85363. * Instantiates a new Ascii Art Post Process.
  85364. * @param name the name to give to the postprocess
  85365. * @camera the camera to apply the post process to.
  85366. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85367. */
  85368. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85369. }
  85370. }
  85371. declare module BABYLON {
  85372. /** @hidden */
  85373. export var digitalrainPixelShader: {
  85374. name: string;
  85375. shader: string;
  85376. };
  85377. }
  85378. declare module BABYLON {
  85379. /**
  85380. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85381. *
  85382. * It basically takes care rendering the font front the given font size to a texture.
  85383. * This is used later on in the postprocess.
  85384. */
  85385. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85386. private _font;
  85387. private _text;
  85388. private _charSize;
  85389. /**
  85390. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85391. */
  85392. get charSize(): number;
  85393. /**
  85394. * Create a new instance of the Digital Rain FontTexture class
  85395. * @param name the name of the texture
  85396. * @param font the font to use, use the W3C CSS notation
  85397. * @param text the caracter set to use in the rendering.
  85398. * @param scene the scene that owns the texture
  85399. */
  85400. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85401. /**
  85402. * Gets the max char width of a font.
  85403. * @param font the font to use, use the W3C CSS notation
  85404. * @return the max char width
  85405. */
  85406. private getFontWidth;
  85407. /**
  85408. * Gets the max char height of a font.
  85409. * @param font the font to use, use the W3C CSS notation
  85410. * @return the max char height
  85411. */
  85412. private getFontHeight;
  85413. /**
  85414. * Clones the current DigitalRainFontTexture.
  85415. * @return the clone of the texture.
  85416. */
  85417. clone(): DigitalRainFontTexture;
  85418. /**
  85419. * Parses a json object representing the texture and returns an instance of it.
  85420. * @param source the source JSON representation
  85421. * @param scene the scene to create the texture for
  85422. * @return the parsed texture
  85423. */
  85424. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85425. }
  85426. /**
  85427. * Option available in the Digital Rain Post Process.
  85428. */
  85429. export interface IDigitalRainPostProcessOptions {
  85430. /**
  85431. * The font to use following the w3c font definition.
  85432. */
  85433. font?: string;
  85434. /**
  85435. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85436. * This number is defined between 0 and 1;
  85437. */
  85438. mixToTile?: number;
  85439. /**
  85440. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85441. * This number is defined between 0 and 1;
  85442. */
  85443. mixToNormal?: number;
  85444. }
  85445. /**
  85446. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85447. *
  85448. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85449. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85450. */
  85451. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85452. /**
  85453. * The font texture used to render the char in the post process.
  85454. */
  85455. private _digitalRainFontTexture;
  85456. /**
  85457. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85458. * This number is defined between 0 and 1;
  85459. */
  85460. mixToTile: number;
  85461. /**
  85462. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85463. * This number is defined between 0 and 1;
  85464. */
  85465. mixToNormal: number;
  85466. /**
  85467. * Instantiates a new Digital Rain Post Process.
  85468. * @param name the name to give to the postprocess
  85469. * @camera the camera to apply the post process to.
  85470. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85471. */
  85472. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85473. }
  85474. }
  85475. declare module BABYLON {
  85476. /** @hidden */
  85477. export var brickProceduralTexturePixelShader: {
  85478. name: string;
  85479. shader: string;
  85480. };
  85481. }
  85482. declare module BABYLON {
  85483. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85484. private _numberOfBricksHeight;
  85485. private _numberOfBricksWidth;
  85486. private _jointColor;
  85487. private _brickColor;
  85488. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85489. updateShaderUniforms(): void;
  85490. get numberOfBricksHeight(): number;
  85491. set numberOfBricksHeight(value: number);
  85492. get numberOfBricksWidth(): number;
  85493. set numberOfBricksWidth(value: number);
  85494. get jointColor(): BABYLON.Color3;
  85495. set jointColor(value: BABYLON.Color3);
  85496. get brickColor(): BABYLON.Color3;
  85497. set brickColor(value: BABYLON.Color3);
  85498. /**
  85499. * Serializes this brick procedural texture
  85500. * @returns a serialized brick procedural texture object
  85501. */
  85502. serialize(): any;
  85503. /**
  85504. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85505. * @param parsedTexture defines parsed texture data
  85506. * @param scene defines the current scene
  85507. * @param rootUrl defines the root URL containing brick procedural texture information
  85508. * @returns a parsed Brick Procedural BABYLON.Texture
  85509. */
  85510. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85511. }
  85512. }
  85513. declare module BABYLON {
  85514. /** @hidden */
  85515. export var cloudProceduralTexturePixelShader: {
  85516. name: string;
  85517. shader: string;
  85518. };
  85519. }
  85520. declare module BABYLON {
  85521. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85522. private _skyColor;
  85523. private _cloudColor;
  85524. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85525. updateShaderUniforms(): void;
  85526. get skyColor(): BABYLON.Color4;
  85527. set skyColor(value: BABYLON.Color4);
  85528. get cloudColor(): BABYLON.Color4;
  85529. set cloudColor(value: BABYLON.Color4);
  85530. /**
  85531. * Serializes this cloud procedural texture
  85532. * @returns a serialized cloud procedural texture object
  85533. */
  85534. serialize(): any;
  85535. /**
  85536. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85537. * @param parsedTexture defines parsed texture data
  85538. * @param scene defines the current scene
  85539. * @param rootUrl defines the root URL containing cloud procedural texture information
  85540. * @returns a parsed Cloud Procedural BABYLON.Texture
  85541. */
  85542. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85543. }
  85544. }
  85545. declare module BABYLON {
  85546. /** @hidden */
  85547. export var fireProceduralTexturePixelShader: {
  85548. name: string;
  85549. shader: string;
  85550. };
  85551. }
  85552. declare module BABYLON {
  85553. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85554. private _time;
  85555. private _speed;
  85556. private _autoGenerateTime;
  85557. private _fireColors;
  85558. private _alphaThreshold;
  85559. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85560. updateShaderUniforms(): void;
  85561. render(useCameraPostProcess?: boolean): void;
  85562. static get PurpleFireColors(): BABYLON.Color3[];
  85563. static get GreenFireColors(): BABYLON.Color3[];
  85564. static get RedFireColors(): BABYLON.Color3[];
  85565. static get BlueFireColors(): BABYLON.Color3[];
  85566. get autoGenerateTime(): boolean;
  85567. set autoGenerateTime(value: boolean);
  85568. get fireColors(): BABYLON.Color3[];
  85569. set fireColors(value: BABYLON.Color3[]);
  85570. get time(): number;
  85571. set time(value: number);
  85572. get speed(): BABYLON.Vector2;
  85573. set speed(value: BABYLON.Vector2);
  85574. get alphaThreshold(): number;
  85575. set alphaThreshold(value: number);
  85576. /**
  85577. * Serializes this fire procedural texture
  85578. * @returns a serialized fire procedural texture object
  85579. */
  85580. serialize(): any;
  85581. /**
  85582. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85583. * @param parsedTexture defines parsed texture data
  85584. * @param scene defines the current scene
  85585. * @param rootUrl defines the root URL containing fire procedural texture information
  85586. * @returns a parsed Fire Procedural BABYLON.Texture
  85587. */
  85588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85589. }
  85590. }
  85591. declare module BABYLON {
  85592. /** @hidden */
  85593. export var grassProceduralTexturePixelShader: {
  85594. name: string;
  85595. shader: string;
  85596. };
  85597. }
  85598. declare module BABYLON {
  85599. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85600. private _grassColors;
  85601. private _groundColor;
  85602. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85603. updateShaderUniforms(): void;
  85604. get grassColors(): BABYLON.Color3[];
  85605. set grassColors(value: BABYLON.Color3[]);
  85606. get groundColor(): BABYLON.Color3;
  85607. set groundColor(value: BABYLON.Color3);
  85608. /**
  85609. * Serializes this grass procedural texture
  85610. * @returns a serialized grass procedural texture object
  85611. */
  85612. serialize(): any;
  85613. /**
  85614. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85615. * @param parsedTexture defines parsed texture data
  85616. * @param scene defines the current scene
  85617. * @param rootUrl defines the root URL containing grass procedural texture information
  85618. * @returns a parsed Grass Procedural BABYLON.Texture
  85619. */
  85620. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85621. }
  85622. }
  85623. declare module BABYLON {
  85624. /** @hidden */
  85625. export var marbleProceduralTexturePixelShader: {
  85626. name: string;
  85627. shader: string;
  85628. };
  85629. }
  85630. declare module BABYLON {
  85631. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85632. private _numberOfTilesHeight;
  85633. private _numberOfTilesWidth;
  85634. private _amplitude;
  85635. private _jointColor;
  85636. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85637. updateShaderUniforms(): void;
  85638. get numberOfTilesHeight(): number;
  85639. set numberOfTilesHeight(value: number);
  85640. get amplitude(): number;
  85641. set amplitude(value: number);
  85642. get numberOfTilesWidth(): number;
  85643. set numberOfTilesWidth(value: number);
  85644. get jointColor(): BABYLON.Color3;
  85645. set jointColor(value: BABYLON.Color3);
  85646. /**
  85647. * Serializes this marble procedural texture
  85648. * @returns a serialized marble procedural texture object
  85649. */
  85650. serialize(): any;
  85651. /**
  85652. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85653. * @param parsedTexture defines parsed texture data
  85654. * @param scene defines the current scene
  85655. * @param rootUrl defines the root URL containing marble procedural texture information
  85656. * @returns a parsed Marble Procedural BABYLON.Texture
  85657. */
  85658. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85659. }
  85660. }
  85661. declare module BABYLON {
  85662. /** @hidden */
  85663. export var normalMapProceduralTexturePixelShader: {
  85664. name: string;
  85665. shader: string;
  85666. };
  85667. }
  85668. declare module BABYLON {
  85669. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85670. private _baseTexture;
  85671. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85672. updateShaderUniforms(): void;
  85673. render(useCameraPostProcess?: boolean): void;
  85674. resize(size: any, generateMipMaps: any): void;
  85675. get baseTexture(): BABYLON.Texture;
  85676. set baseTexture(texture: BABYLON.Texture);
  85677. /**
  85678. * Serializes this normal map procedural texture
  85679. * @returns a serialized normal map procedural texture object
  85680. */
  85681. serialize(): any;
  85682. /**
  85683. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85684. * @param parsedTexture defines parsed texture data
  85685. * @param scene defines the current scene
  85686. * @param rootUrl defines the root URL containing normal map procedural texture information
  85687. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85688. */
  85689. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85690. }
  85691. }
  85692. declare module BABYLON {
  85693. /** @hidden */
  85694. export var perlinNoiseProceduralTexturePixelShader: {
  85695. name: string;
  85696. shader: string;
  85697. };
  85698. }
  85699. declare module BABYLON {
  85700. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85701. time: number;
  85702. timeScale: number;
  85703. translationSpeed: number;
  85704. private _currentTranslation;
  85705. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85706. updateShaderUniforms(): void;
  85707. render(useCameraPostProcess?: boolean): void;
  85708. resize(size: any, generateMipMaps: any): void;
  85709. /**
  85710. * Serializes this perlin noise procedural texture
  85711. * @returns a serialized perlin noise procedural texture object
  85712. */
  85713. serialize(): any;
  85714. /**
  85715. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85716. * @param parsedTexture defines parsed texture data
  85717. * @param scene defines the current scene
  85718. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85719. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85720. */
  85721. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85722. }
  85723. }
  85724. declare module BABYLON {
  85725. /** @hidden */
  85726. export var roadProceduralTexturePixelShader: {
  85727. name: string;
  85728. shader: string;
  85729. };
  85730. }
  85731. declare module BABYLON {
  85732. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85733. private _roadColor;
  85734. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85735. updateShaderUniforms(): void;
  85736. get roadColor(): BABYLON.Color3;
  85737. set roadColor(value: BABYLON.Color3);
  85738. /**
  85739. * Serializes this road procedural texture
  85740. * @returns a serialized road procedural texture object
  85741. */
  85742. serialize(): any;
  85743. /**
  85744. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85745. * @param parsedTexture defines parsed texture data
  85746. * @param scene defines the current scene
  85747. * @param rootUrl defines the root URL containing road procedural texture information
  85748. * @returns a parsed Road Procedural BABYLON.Texture
  85749. */
  85750. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85751. }
  85752. }
  85753. declare module BABYLON {
  85754. /** @hidden */
  85755. export var starfieldProceduralTexturePixelShader: {
  85756. name: string;
  85757. shader: string;
  85758. };
  85759. }
  85760. declare module BABYLON {
  85761. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85762. private _time;
  85763. private _alpha;
  85764. private _beta;
  85765. private _zoom;
  85766. private _formuparam;
  85767. private _stepsize;
  85768. private _tile;
  85769. private _brightness;
  85770. private _darkmatter;
  85771. private _distfading;
  85772. private _saturation;
  85773. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85774. updateShaderUniforms(): void;
  85775. get time(): number;
  85776. set time(value: number);
  85777. get alpha(): number;
  85778. set alpha(value: number);
  85779. get beta(): number;
  85780. set beta(value: number);
  85781. get formuparam(): number;
  85782. set formuparam(value: number);
  85783. get stepsize(): number;
  85784. set stepsize(value: number);
  85785. get zoom(): number;
  85786. set zoom(value: number);
  85787. get tile(): number;
  85788. set tile(value: number);
  85789. get brightness(): number;
  85790. set brightness(value: number);
  85791. get darkmatter(): number;
  85792. set darkmatter(value: number);
  85793. get distfading(): number;
  85794. set distfading(value: number);
  85795. get saturation(): number;
  85796. set saturation(value: number);
  85797. /**
  85798. * Serializes this starfield procedural texture
  85799. * @returns a serialized starfield procedural texture object
  85800. */
  85801. serialize(): any;
  85802. /**
  85803. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85804. * @param parsedTexture defines parsed texture data
  85805. * @param scene defines the current scene
  85806. * @param rootUrl defines the root URL containing startfield procedural texture information
  85807. * @returns a parsed Starfield Procedural BABYLON.Texture
  85808. */
  85809. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85810. }
  85811. }
  85812. declare module BABYLON {
  85813. /** @hidden */
  85814. export var woodProceduralTexturePixelShader: {
  85815. name: string;
  85816. shader: string;
  85817. };
  85818. }
  85819. declare module BABYLON {
  85820. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85821. private _ampScale;
  85822. private _woodColor;
  85823. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85824. updateShaderUniforms(): void;
  85825. get ampScale(): number;
  85826. set ampScale(value: number);
  85827. get woodColor(): BABYLON.Color3;
  85828. set woodColor(value: BABYLON.Color3);
  85829. /**
  85830. * Serializes this wood procedural texture
  85831. * @returns a serialized wood procedural texture object
  85832. */
  85833. serialize(): any;
  85834. /**
  85835. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85836. * @param parsedTexture defines parsed texture data
  85837. * @param scene defines the current scene
  85838. * @param rootUrl defines the root URL containing wood procedural texture information
  85839. * @returns a parsed Wood Procedural BABYLON.Texture
  85840. */
  85841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85842. }
  85843. }